From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Michael Matz <matz@suse.de>, gnu-gabi@sourceware.org
Subject: Re: Specify how undefined weak symbol should be resolved in executable
Date: Fri, 01 Jan 2016 00:00:00 -0000 [thread overview]
Message-ID: <20160223044029.GE10657@bubble.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOq=aMiTZ_nwS9aO9ba5bj_ak4gpk9D+JSfwged70VM3mg@mail.gmail.com>
On Mon, Feb 22, 2016 at 02:43:55PM -0800, H.J. Lu wrote:
> we create executable with dynamic R_X86_64_32 relocation against
> fun .text section, which leads to DT_TEXTREL. Is this what we want?
I think that avoiding DT_TEXTREL is historically why we haven't
supported weak symbols well in non-PIC executables. Another closely
related issue is the old hack written into most ABIs that the address
of a function referenced in an executable and defined in a shared
library is the address of that function's PLT code in the executable.
Note that this affects both defined and undefined weak functions in
non-PIC executables. Currently, if we find a definition for "fun" at
link time in a shared library, "&fun" is the PLT entry in the
executable and "if (&fun)" effectively becomes "if (1)". So if you
link the executable with a shared library containing a definition of
"fun" but at run-time load a newer shared library *not* defining "fun",
your program will segfault.
Therefore, if the aim is to make PIC and non-PIC executables behave
the same you need to change defined weak symbol behaviour too. Any
non-PIC executable that takes the address of a weak function in code
or rodata would become DT_TEXTREL.
However, that might be a bad idea. Lots of C++ code uses weak symbols
for functions defined in header files, and other objects with vague
linkage. These result in weak definitions in eg. libstdc++.so. I'm
not sure how many executables take the address of such functions and
thus might become DT_TEXTREL.
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2016-02-23 4:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-01 0:00 H.J. Lu
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Alan Modra [this message]
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Alan Modra
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Alan Modra
2016-01-01 0:00 ` Carlos O'Donell
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` Szabolcs Nagy
2016-01-01 0:00 ` Michael Matz
2016-01-01 0:00 ` H.J. Lu
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=20160223044029.GE10657@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=gnu-gabi@sourceware.org \
--cc=hjl.tools@gmail.com \
--cc=matz@suse.de \
/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).