This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: RFC: PATCH: PR x86_64/584: Detect call on protected symbol
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"),