public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: Florian Weimer <fweimer@redhat.com>
Cc: Nick Clifton <nickc@redhat.com>, binutils@sourceware.org
Subject: Re: Named local symbols in the ELF dynamic symbol table
Date: Wed, 14 Dec 2022 10:05:20 -1000	[thread overview]
Message-ID: <20221214200520.xjo2hbydr2znowxr@gmail.com> (raw)
In-Reply-To: <87edt8jxag.fsf@oldenburg.str.redhat.com>

I have only seen one reason where STB_LOCAL symbols in .dynsym are useful:
unaligned absolute relocations for ppc32/ppc64
https://sourceware.org/bugzilla/show_bug.cgi?id=24896 .

If the ia64 .dynsym STB_LOCAL symbols are not used by special
relocations, it's likely a minor issue/missing improvement in ld's ia64
port.

On 2022-12-09, Florian Weimer via Binutils wrote:
>* Nick Clifton:
>
>> Hi Florian,
>>
>>> Is there a way to get the same effect on other targets?
>>
>> How are the loaders for other targets linked ?  If they include the
>> -X or --discard-locals option on the command line, then removing that
>> option might achieve the result that you desire.
>
>I'm using:
>
>  gcc -nostdlib -nostartfiles -shared -o …/build/elf/ld.so.new \
>          -Wl,-z,relro -Wl,-z,defs \
>          …/build/elf/librtld.os -Wl,--version-script=…/build/ld.map \
>          -Wl,-soname=ld-linux-x86-64.so.2
>
>gcc -v tells me:
>
>/usr/libexec/gcc/x86_64-redhat-linux/11/collect2 \
>  -plugin /usr/libexec/gcc/x86_64-redhat-linux/11/liblto_plugin.so \
>  -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper \
>  -plugin-opt=-fresolution=/tmp/ccHaMg3U.res --build-id --no-add-needed \
>  --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -shared \
>  -o …/build/elf/ld.so.new -L/usr/lib/gcc/x86_64-redhat-linux/11 \
>  -L/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64 -L/lib/../lib64 \
>  -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/11/../../.. \
>  -z relro -z defs …/build/elf/librtld.os --version-script=…/build/ld.map \
>  -soname=ld-linux-x86-64.so.2
>
>So it seems that -X or --discard-locals is the default?  How do I
>override that, preferably for specific symbols only?

-X should be irrelevant for .dynsym entries.

-X is not the default for almost all ports, but ld/emultempl/riscvelf.em
has a hack to default to --discard-locals. That was copied by loongarch
[Facepalm]. The proper way is to encode the logic in compiler drivers
(I did this for Clang in https://reviews.llvm.org/D127826).

>>> It would best
>>> if I wouldn't have to bloat the entire symbol table for that.
>>
>> I don't think that you have symbol names without having entries in
>> the symbol table.  Although as you say, if they are local symbols
>> then they will not also take up room in the GNU_HASH table.
>
>Yeah, should have said symbol hash table.  I really want them in .dynsym
>actually.
>
>Thanks,
>Florian
>

  parent reply	other threads:[~2022-12-14 20:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 17:11 Florian Weimer
2022-12-08 13:19 ` Nick Clifton
2022-12-09 17:34   ` Florian Weimer
2022-12-14 15:31     ` Nick Clifton
2022-12-14 20:05     ` Fangrui Song [this message]
2022-12-14 21:44 ` H.J. Lu
2022-12-14 21:53   ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221214200520.xjo2hbydr2znowxr@gmail.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).