History

scripts/sorttable: Remove unneeded Elf_Rel

The code had references to initialize the Elf_Rel relocation tables, but it was never used. Remove it.

Steven Rostedt committed 1 year ago

Commit 6f2c2f91 parent 4f48a281 file · +2 −21Browse files

Unified · Split

scripts/sorttable.h+2−21
@@ -26,7 +26,6 @@ · 25 unmodified lines
26#undef Elf_Addr26#undef Elf_Addr
27#undef Elf_Ehdr27#undef Elf_Ehdr
28#undef Elf_Shdr28#undef Elf_Shdr
29#undef Elf_Rel
30#undef Elf_Sym29#undef Elf_Sym
31#undef ELF_ST_TYPE30#undef ELF_ST_TYPE
32#undef uint_t31#undef uint_t
@@ -42,7 +41,6 @@ · 9 unmodified lines
42# define Elf_Addr Elf64_Addr41# define Elf_Addr Elf64_Addr
43# define Elf_Ehdr Elf64_Ehdr42# define Elf_Ehdr Elf64_Ehdr
44# define Elf_Shdr Elf64_Shdr43# define Elf_Shdr Elf64_Shdr
45# define Elf_Rel Elf64_Rel
46# define Elf_Sym Elf64_Sym44# define Elf_Sym Elf64_Sym
47# define ELF_ST_TYPE ELF64_ST_TYPE45# define ELF_ST_TYPE ELF64_ST_TYPE
48# define uint_t uint64_t46# define uint_t uint64_t
@@ -57,7 +55,6 @@ · 8 unmodified lines
57# define Elf_Addr Elf32_Addr55# define Elf_Addr Elf32_Addr
58# define Elf_Ehdr Elf32_Ehdr56# define Elf_Ehdr Elf32_Ehdr
59# define Elf_Shdr Elf32_Shdr57# define Elf_Shdr Elf32_Shdr
60# define Elf_Rel Elf32_Rel
61# define Elf_Sym Elf32_Sym58# define Elf_Sym Elf32_Sym
62# define ELF_ST_TYPE ELF32_ST_TYPE59# define ELF_ST_TYPE ELF32_ST_TYPE
63# define uint_t uint32_t60# define uint_t uint32_t
@@ -248,14 +245,10 @@ static int do_sort(Elf_Ehdr *ehdr, · 184 unmodified lines
248 Elf32_Word *symtab_shndx = NULL;245 Elf32_Word *symtab_shndx = NULL;
249 Elf_Sym *sort_needed_sym = NULL;246 Elf_Sym *sort_needed_sym = NULL;
250 Elf_Shdr *sort_needed_sec;247 Elf_Shdr *sort_needed_sec;
251 Elf_Rel *relocs = NULL;
252 int relocs_size = 0;
253 uint32_t *sort_needed_loc;248 uint32_t *sort_needed_loc;
254 const char *secstrings;249 const char *secstrings;
255 const char *strtab;250 const char *strtab;
256 char *extab_image;251 char *extab_image;
257 int extab_index = 0;
258 int i;
259 int idx;252 int idx;
260 unsigned int shnum;253 unsigned int shnum;
261 unsigned int shstrndx;254 unsigned int shstrndx;
@@ -279,23 +272,15 @@ static int do_sort(Elf_Ehdr *ehdr, · 17 unmodified lines
279 if (shnum == SHN_UNDEF)272 if (shnum == SHN_UNDEF)
280 shnum = _r(&shdr[0].sh_size);273 shnum = _r(&shdr[0].sh_size);
281 274
282 for (i = 0, s = shdr; s < shdr + shnum; i++, s++) {275 for (s = shdr; s < shdr + shnum; s++) {
283 idx = r(&s->sh_name);276 idx = r(&s->sh_name);
284 if (!strcmp(secstrings + idx, "__ex_table")) {277 if (!strcmp(secstrings + idx, "__ex_table"))
285 extab_sec = s;278 extab_sec = s;
286 extab_index = i;
287 }
288 if (!strcmp(secstrings + idx, ".symtab"))279 if (!strcmp(secstrings + idx, ".symtab"))
289 symtab_sec = s;280 symtab_sec = s;
290 if (!strcmp(secstrings + idx, ".strtab"))281 if (!strcmp(secstrings + idx, ".strtab"))
291 strtab_sec = s;282 strtab_sec = s;
292 283
293 if ((r(&s->sh_type) == SHT_REL ||
294 r(&s->sh_type) == SHT_RELA) &&
295 r(&s->sh_info) == extab_index) {
296 relocs = (void *)ehdr + _r(&s->sh_offset);
297 relocs_size = _r(&s->sh_size);
298 }
299 if (r(&s->sh_type) == SHT_SYMTAB_SHNDX)284 if (r(&s->sh_type) == SHT_SYMTAB_SHNDX)
300 symtab_shndx = (Elf32_Word *)((const char *)ehdr +285 symtab_shndx = (Elf32_Word *)((const char *)ehdr +
301 _r(&s->sh_offset));286 _r(&s->sh_offset));
@@ -397,10 +382,6 @@ static int do_sort(Elf_Ehdr *ehdr, · 95 unmodified lines
397 extable_ent_size, compare_extable);382 extable_ent_size, compare_extable);
398 }383 }
399 384
400 /* If there were relocations, we no longer need them. */
401 if (relocs)
402 memset(relocs, 0, relocs_size);
403
404 /* find the flag main_extable_sort_needed */385 /* find the flag main_extable_sort_needed */
405 for (sym = (void *)ehdr + _r(&symtab_sec->sh_offset);386 for (sym = (void *)ehdr + _r(&symtab_sec->sh_offset);
406 sym < sym + _r(&symtab_sec->sh_size) / sizeof(Elf_Sym);387 sym < sym + _r(&symtab_sec->sh_size) / sizeof(Elf_Sym);