/* * now we need to walk through the section headers and collect the * sizes of the .text sections to be randomized.*/for(i =0; i < shnum; i++){ s =&sechdrs[i]; sname = secstrings +s->sh_name;if(s->sh_type== SHT_SYMTAB){/* only one symtab per image */if(symtab)error("Unexpected duplicate symtab"); symtab =malloc(s->sh_size);if(!symtab)error("Failed to allocate space for symtab");memcpy(symtab, output +s->sh_offset,s->sh_size); num_syms =s->sh_size/sizeof(*symtab);continue;}if(s->sh_type== SHT_STRTAB && i !=ehdr->e_shstrndx){if(strtab)error("Unexpected duplicate strtab"); strtab =malloc(s->sh_size);if(!strtab)error("Failed to allocate space for strtab");memcpy(strtab, output +s->sh_offset,s->sh_size);}if(!strcmp(sname,".text")){if(text)error("Unexpected duplicate .text section"); text = s;continue;}if(!strcmp(sname,".data..percpu")){/* get start addr for later */ percpu = s;continue;}if(!(s->sh_flags& SHF_ALLOC)||!(s->sh_flags& SHF_EXECINSTR)||!(strstarts(sname,".text")))continue;sections[num_sections]= s; num_sections++;}sections[num_sections]=NULL; sections_size = num_sections;