From: "H. J. Lu" <hjl@lucon.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: binutils@sources.redhat.com
Subject: Re: RFC: PATCH: PR x86_64/584: Detect call on protected symbol
Date: Thu, 20 Jan 2005 00:51:00 -0000 [thread overview]
Message-ID: <20050120005101.GA5904@lucon.org> (raw)
In-Reply-To: <20050120004032.GA5734@lucon.org>
On Wed, Jan 19, 2005 at 04:40:32PM -0800, H. J. Lu wrote:
> On Thu, Jan 20, 2005 at 12:05:44AM +0100, Jakub Jelinek wrote:
> > On Wed, Jan 19, 2005 at 02:48:34PM -0800, H. J. Lu wrote:
> > > X86_64 uses R_X86_64_PC32 for both branch and store/load. Linker
> > > can't tell if a protected symbol reference is local or global just
> > > by relocation. This patch disassembles the code to check for call.
> >
> > Eh, why you need the disassembler there?
> > Isn't it enough just to check if R_X86_64_PC32's r_offset > 0 and
> > contents[r_offset - 1] == 0xe8?
>
> Can we be sure that contents[r_offset - 1] == 0xe8 will be call?
>
>
If we are, here is a patch.
H.J.
----
2005-01-19 H.J. Lu <hongjiu.lu@intel.com>
PR 584
* elf64-x86-64.c (elf64_x86_64_relocate_section): Alllow
R_X86_64_PC32 on a protected function symbol when building
shared library for call instruction.
--- bfd/elf64-x86-64.c.prot 2005-01-11 09:10:28.000000000 -0800
+++ bfd/elf64-x86-64.c 2005-01-19 16:47:36.561055001 -0800
@@ -1950,7 +1950,12 @@ elf64_x86_64_relocate_section (bfd *outp
if (info->shared
&& !SYMBOL_REFERENCES_LOCAL (info, h)
&& (input_section->flags & SEC_ALLOC) != 0
- && (input_section->flags & SEC_READONLY) != 0)
+ && (input_section->flags & SEC_READONLY) != 0
+ && (!h->def_regular
+ || r_type != R_X86_64_PC32
+ || h->type != STT_FUNC
+ || ELF_ST_VISIBILITY (h->other) != STV_PROTECTED
+ || contents [rel->r_offset - 1] != 0xe8))
{
(*_bfd_error_handler)
(_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
next prev parent reply other threads:[~2005-01-20 0:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-19 22:49 H. J. Lu
2005-01-19 23:06 ` Jakub Jelinek
2005-01-20 0:40 ` H. J. Lu
2005-01-20 0:51 ` H. J. Lu [this message]
2005-01-20 1:55 ` Alan Modra
2005-01-20 3:17 ` H. J. Lu
2005-01-20 4:22 ` Alan Modra
2005-01-20 6:38 ` H. J. Lu
2005-01-20 10:19 ` Andreas Schwab
2005-01-20 17:34 ` H. J. Lu
2005-01-24 23:26 ` PATCH: Properly handle protected function for ia32 and x86_64 H. J. Lu
2005-01-30 10:22 ` Andreas Jaeger
2005-02-01 4:51 ` Alan Modra
2005-02-01 5:50 ` H. J. Lu
2005-02-01 7:44 ` Alan Modra
2005-02-01 15:23 ` 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=20050120005101.GA5904@lucon.org \
--to=hjl@lucon.org \
--cc=binutils@sources.redhat.com \
--cc=jakub@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).