This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld and R_386_GOTOFF relocs
- From: "Peter S. Mazinger" <ps dot m at gmx dot net>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: binutils at sourceware dot org, <gcc at gcc dot gnu dot org>
- Date: Thu, 12 May 2005 23:33:25 +0200 (CEST)
- Subject: Re: ld and R_386_GOTOFF relocs
On Thu, 12 May 2005, H. J. Lu wrote:
> On Thu, May 12, 2005 at 08:13:27AM +0200, Peter S. Mazinger wrote:
> > On Wed, 11 May 2005, H. J. Lu wrote:
> >
> > > On Thu, May 12, 2005 at 12:48:46AM +0200, Peter S. Mazinger wrote:
> > > > Hello!
> > > >
> > > > I have gotten under peculiar circumstances following:
> > > > (sysvinit) init.o: relocation R_386_GOTOFF against protected function
> > > > `main' can not be used when making a shared object
> > > >
> > > > libc.so does not provide a weak 'main', main() is in crt1.o defined in asm
> > > > as '.protected main'.
> > > >
> > > > init is built as -pie executable.
> > > >
> > > > I think this check is valid if a shared lib is created, but not valid for
> > > > a PIE executable.
> > > >
> > > > I think, that a check info->shared should be changed to
> > > > info->shared && !info->pie (or !info->executable), to allow pie to be
> > > > linked, but I can't locate the one needed for this.
> > > >
> > > > Thanks, Peter
> > >
> > > This is a gcc bug
> > >
> > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19520
> >
> > Reading through this, I came to the patch you posted on 2005-02-06 for
> > elf32-i386.c. The comment says:
> >
> > +2005-02-06 H.J. Lu <hongjiu.lu@intel.com>
> > +
> > + * elf32-i386.c (elf_i386_relocate_section): Disallow R_386_GOTOFF
> > + against protected function when building shared library.
> >
> > If you intented to do this only for shared libraries, but not for PIE
> > executables, then info->shared is incorrect, and as I proposed has to be
> > changed.
> >
>
> I checked in the following patch.
Thanks, your patched solved it.
Peter
>
> FYI, using protected function in executable has no benefit since
> noone can override function in executable anyway.
>
>
> H.J.
> ----
> 2005-05-12 H.J. Lu <hongjiu.lu@intel.com>
>
> * elf32-i386.c (elf_i386_relocate_section): Allow R_386_GOTOFF
> against protected function when building executable.
>
> --- bfd/elf32-i386.c.pie 2005-05-12 10:00:49.000000000 -0700
> +++ bfd/elf32-i386.c 2005-05-12 13:55:04.000000000 -0700
> @@ -2390,6 +2390,7 @@ elf_i386_relocate_section (bfd *output_b
> for shared library since it may not be local when used
> as function address. */
> if (info->shared
> + && !info->executable
> && h
> && h->def_regular
> && h->type == STT_FUNC
>
>
--
Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2