[PATCH v3] elf: Keep unused section symbols for Solaris binary
Fangrui Song
maskray@sourceware.org
Wed Dec 10 08:31:46 GMT 2025
More information about the Binutils mailing list
Wed Dec 10 08:31:46 GMT 2025
- Previous message (by thread): [PATCH v3] elf: Keep unused section symbols for Solaris binary
- Next message (by thread): [PATCH] Add windres to TOOL_PROGS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Dec 8, 2025 at 11:33 PM Jan Beulich <jbeulich@suse.com> wrote: > > On 09.12.2025 08:18, H.J. Lu wrote: > > On Mon, Dec 8, 2025 at 3:52 PM Jan Beulich <jbeulich@suse.com> wrote: > >> > >> On 06.12.2025 04:04, H.J. Lu wrote: > >>> After > >>> > >>> commit d1bcae833b32f1408485ce69f844dcd7ded093a8 > >>> Author: H.J. Lu <hjl.tools@gmail.com> > >>> Date: Thu Jan 7 06:42:00 2021 -0800 > >>> > >>> ELF: Don't generate unused section symbols > >>> > >>> x86 ELF binutils tools no longer generate unused section symbols. But > >>> Solaris binary generated by Solaris linker may include symbol sort > >>> sections which hold indexes of data and function symbols, sorted by name > >>> or by address. When objcopy removes section symbols, it corrupts Solaris > >>> symbol sort sections since symbol indexes are changed. Keep section > >>> symbols for Solaris binary. > >>> > >>> PR binutils/33684 > >>> * objcopy.c (copy_object): Keep section symbols if input is a > >>> Solaris binary and output target is the same as input target. > >> > >> Hmm, an open-coded OSABI check in objcopy. I was expecting change in libbfd > >> to e.g. make bfd_keep_unused_section_symbols() on ibfd true for Solaris, to > >> then copy that property to obfd. Is there a reason to not try to somewhat > >> abstract what is wanted / needed? > > > > Here is the v3 patch with the updated bfd_keep_unused_section_symbols. > > > > After > > > > commit d1bcae833b32f1408485ce69f844dcd7ded093a8 > > Author: H.J. Lu <hjl.tools@gmail.com> > > Date: Thu Jan 7 06:42:00 2021 -0800 > > > > ELF: Don't generate unused section symbols > > > > x86 ELF binutils tools no longer generate unused section symbols. But > > Solaris binary generated by Solaris linker may include symbol sort > > sections which hold indexes of data and function symbols, sorted by name > > or by address. When objcopy removes section symbols, it corrupts Solaris > > symbol sort sections since symbol indexes are changed. > > > > 1. Update bfd_keep_unused_section_symbols to return true for Solaris > > binary. > > 2. Keep section symbols if input section symbols should be kept and > > output target is the same as input target. > > This is okay afaic, but please give Rainer and/or Ali a chance to comment. > > Irrespective I have a question here, though (perhaps also to Alan and Nick): > Isn't it wrong for objcopy to remove _any_ symbols (including section ones) > without an explicit request to do so? IOW shouldn't objcopy without any > specific options largely generate an output identical to the input? > > Jan Ideally, objcopy would only rewrite the symbol table when absolutely necessary. Achieving this appears challenging per comments around https://sourceware.org/bugzilla/show_bug.cgi?id=33684#c16 In related efforts, LLVM's integrated assembler has been removing unneeded section symbols since 2015. I reported "gas: Omit unused STT_SECTION symbols" (https://sourceware.org/bugzilla/show_bug.cgi?id=27109) in 2020. I appreciate that HJ has implemented this for x86 and hope other ports will follow suit. (Elf64_Sym is expensive )
- Previous message (by thread): [PATCH v3] elf: Keep unused section symbols for Solaris binary
- Next message (by thread): [PATCH] Add windres to TOOL_PROGS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list