From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id D31583858C42; Tue, 23 Apr 2024 12:37:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D31583858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713875864; bh=F6VxsD6szV+BWOEKRBaa4ZVR2wWcbY3bE/8O2k1VnFk=; h=From:To:Subject:Date:From; b=UogNDZ8K+zLM4WSJ/ZZvnaEin81c/GO5NvyxrXQpDOxnb9nikxr6r6vEdgRXTHkZ0 d2f2/oE5ZESsrWA0HDXLJ2WjBxdaZMSG/vUoPanHbp9+64De+XxhME1zVyiEzCOxeg 9scjiqT+vQrKiEGRtpvgrEKcxhCXeSuZJHLF9cOM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] copy_private_symbol_data X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 6bfde7e33e2220766b82abd5b88b4b33028d260a X-Git-Newrev: 6705e14a9943e48ccf0f4829a9c23d66b5b83aae Message-Id: <20240423123744.D31583858C42@sourceware.org> Date: Tue, 23 Apr 2024 12:37:44 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6705e14a9943= e48ccf0f4829a9c23d66b5b83aae commit 6705e14a9943e48ccf0f4829a9c23d66b5b83aae Author: Alan Modra Date: Mon Apr 22 09:30:23 2024 +0930 copy_private_symbol_data =20 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. =20 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. =20 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 =3D MAP_ONESYMTAB; else if (shndx =3D=3D elf_dynsymtab (ibfd)) shndx =3D MAP_DYNSYMTAB; - else if (shndx =3D=3D elf_strtab_sec (ibfd)) + else if (shndx =3D=3D elf_elfsections (ibfd)[elf_onesymtab (ibfd)]->= sh_link) shndx =3D MAP_STRTAB; - else if (shndx =3D=3D elf_shstrtab_sec (ibfd)) + else if (shndx =3D=3D elf_elfheader (ibfd)->e_shstrndx) shndx =3D MAP_SHSTRTAB; else if (find_section_in_list (shndx, elf_symtab_shndx_list (ibfd))) shndx =3D MAP_SYM_SHNDX;