[PATCH v3] elf: Keep unused section symbols for Solaris binary

Ali Bahrami ali.bahrami@oracle.com
Wed Dec 10 02:47:51 GMT 2025


On 12/9/25 7:20 PM, H.J. Lu wrote:
>> Since I'm opining, I'll also ask why this isn't more
>> appropriately done only by the link-editor. I'd say
>> that if gld doesn't want section symbols, it doesn't
>> need to make them, but that objcopy ought (by default)
>> to preserve the choice made by the link-editor.
> It is

    Yes, with your patch to make the Solaris ELFOSABI a special
case, it preserves them, and I said so:

     > Having done that, it builds, and it seems to preserve
     > the section symbols, so it addresses my main concern.

But it wouldn't preserve them otherwise. Note that I was
responding to Jan's question, which is general, and not
about Solaris specifically:

     > 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?

If it worked that way, there would be no need for a special
case for Solaris, and the behavior of binutils in this regard
would be consistent between x86 and other platforms.

- Ali



More information about the Binutils mailing list