From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] x86: Ignore protected visibility in shared libraries on Solaris
Date: Wed, 24 Aug 2022 11:10:56 +0930 [thread overview]
Message-ID: <YwWBqL3ndlXIrkHw@squeak.grove.modra.org> (raw)
In-Reply-To: <YwVt4A8kfPVcMMFr@squeak.grove.modra.org>
On Wed, Aug 24, 2022 at 09:46:32AM +0930, Alan Modra wrote:
> On Tue, Aug 23, 2022 at 10:34:32AM -0700, H.J. Lu via Binutils wrote:
> > On x86, the PLT entry in executable may be used as function address for
> > functions in shared libraries. If functions are protected, the function
> > address used in executable can be different from the function address
> > used in shared library. This will lead to incorrect run-time behavior
> > if function pointer equality is needed. By default, x86 linker issues
> > an error in this case.
> >
> > On Solaris, linker issued an error for
> >
> > struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt);
> >
> > where gmtime is a protected function in libc.so. Use gmtime's PLT entry
> > in executable as function address is safe since function pointer equality
> > isn't needed.
>
> I'm curious as to how pointer_equality_needed came to be set for
> gmtime.
Hmm, I figure it was -fno-PIC code with a R_X86_64_32 or R_X86_64_64
referencing gmtime. And yes, -fno-PIC -mcmodel=medium will generate
R_X86_64_32 in a testcase like
extern int f1 (int);
extern int f2 (int);
int foo (int what, int val) { return (what ? f1 : f2) (val); }
So why exclude R_X86_64_32 with an ABI_64_P test before setting
func_pointer_ref in elf_x86_64_scan_relocs?
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2022-08-24 1:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 17:34 H.J. Lu
2022-08-24 0:16 ` Alan Modra
2022-08-24 1:40 ` Alan Modra [this message]
2022-08-24 14:36 ` 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=YwWBqL3ndlXIrkHw@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.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).