public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] copy_private_symbol_data
@ 2024-04-23 12:37 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2024-04-23 12:37 UTC (permalink / raw)
  To: binutils-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6705e14a9943e48ccf0f4829a9c23d66b5b83aae

commit 6705e14a9943e48ccf0f4829a9c23d66b5b83aae
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Apr 22 09:30:23 2024 +0930

    copy_private_symbol_data
    
    bfd_copy_private_symbol_data is a bfd function that appeared in
    commit 89665c8562da a long time ago, but seemingly wasn't used
    anywhere until Jan added it to gas/symbols.c in commit 6a2b6326c21e.
    
    The function is used to modify ELF symbol st_shndx for symbols defined
    in odd sections like .symtab, so that they get the corresponding
    section st_shndx in an output file.  This patch fixes some bitrot in
    the function.  After commit c03551323c04 which introduced
    output_elf_obj_tdata, elf_strtab_sec and elf_shstrtab_sec will
    segfault if used on an input bfd.
    
            PR 14493
            * elf.c (_bfd_elf_copy_private_symbol_data): Don't use
            elf_strtab_sec and elf_shstrtab_sec.

Diff:
---
 bfd/elf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index 52a6a2f56c3..41ec649ebab 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8785,9 +8785,9 @@ _bfd_elf_copy_private_symbol_data (bfd *ibfd,
 	shndx = MAP_ONESYMTAB;
       else if (shndx == elf_dynsymtab (ibfd))
 	shndx = MAP_DYNSYMTAB;
-      else if (shndx == elf_strtab_sec (ibfd))
+      else if (shndx == elf_elfsections (ibfd)[elf_onesymtab (ibfd)]->sh_link)
 	shndx = MAP_STRTAB;
-      else if (shndx == elf_shstrtab_sec (ibfd))
+      else if (shndx == elf_elfheader (ibfd)->e_shstrndx)
 	shndx = MAP_SHSTRTAB;
       else if (find_section_in_list (shndx, elf_symtab_shndx_list (ibfd)))
 	shndx = MAP_SYM_SHNDX;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-23 12:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 12:37 [binutils-gdb] copy_private_symbol_data Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).