aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-09-02 09:56:11 +0930
committerAlan Modra <amodra@gmail.com>2021-09-02 13:48:21 +0930
commitb03b65e2aa3243bc0224ba3f933a3e94f1eed8a1 (patch)
treea2bc19c802d9ae973d9af4a0203bbe4594759c5f /bfd/elf.c
parent36f61bf2ad936edfb76eda706eb3b081a61d5a5a (diff)
downloadgdb-b03b65e2aa3243bc0224ba3f933a3e94f1eed8a1.zip
gdb-b03b65e2aa3243bc0224ba3f933a3e94f1eed8a1.tar.gz
gdb-b03b65e2aa3243bc0224ba3f933a3e94f1eed8a1.tar.bz2
SHT_SYMTAB_SHNDX handling
.symtab_shndx section contents is an array, one entry for each symbol in .symtab, present when the number of symbols exceeds a little less than 64k. Since the mapping is 1-1 with symbols there is no need to keep both dest_index and destshndx_index in elf_sym_strtab. Instead, just make sure that the shndx pointers to the swap functions are kept NULL when .symtab_shndx does not exist. Also, strtabcount in the linker's elf hash table is incremented in lock-step with the output symcount, so that can disappear too.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 380d64d..dea3bb0 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8095,7 +8095,6 @@ swap_out_syms (bfd *abfd,
bfd_byte *outbound_syms;
bfd_byte *outbound_shndx;
unsigned long outbound_syms_index;
- unsigned long outbound_shndx_index;
unsigned int idx;
unsigned int num_locals;
size_t amt;
@@ -8144,7 +8143,6 @@ swap_out_syms (bfd *abfd,
outbound_syms_index = 0;
outbound_shndx = NULL;
- outbound_shndx_index = 0;
if (elf_symtab_shndx_list (abfd))
{
@@ -8180,10 +8178,7 @@ swap_out_syms (bfd *abfd,
sym.st_target_internal = 0;
symstrtab[0].sym = sym;
symstrtab[0].dest_index = outbound_syms_index;
- symstrtab[0].destshndx_index = outbound_shndx_index;
outbound_syms_index++;
- if (outbound_shndx != NULL)
- outbound_shndx_index++;
}
name_local_sections
@@ -8415,11 +8410,8 @@ Unable to handle section index %x in ELF symbol. Using ABS instead."),
idx++;
symstrtab[idx].sym = sym;
symstrtab[idx].dest_index = outbound_syms_index;
- symstrtab[idx].destshndx_index = outbound_shndx_index;
outbound_syms_index++;
- if (outbound_shndx != NULL)
- outbound_shndx_index++;
}
/* Finalize the .strtab section. */
@@ -8444,9 +8436,9 @@ Unable to handle section index %x in ELF symbol. Using ABS instead."),
(outbound_syms
+ (elfsym->dest_index
* bed->s->sizeof_sym)),
- (outbound_shndx
- + (elfsym->destshndx_index
- * sizeof (Elf_External_Sym_Shndx))));
+ NPTR_ADD (outbound_shndx,
+ (elfsym->dest_index
+ * sizeof (Elf_External_Sym_Shndx))));
}
free (symstrtab);