This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerpC pointer_equality_needed optimisation


On Sun, Feb 24, 2008 at 10:10:26AM +1030, Alan Modra wrote:
> On Sat, Feb 23, 2008 at 02:50:30PM -0800, H.J. Lu wrote:
> > Hi Alan,
> > 
> > Is this related to
> > 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32219
> > 
> > Does the testcase work with PIE on PPC?
> 
> Yes it does, and I expect that making the ref_regular_nonweak change
> to x86 ld with make it work on x86 too.
> 
> > >  +                   (*_bfd_error_handler)
> > >  +                     (_("weak reference to %s in non-pic code"
> > >  +                        " will break function pointer comparisons"),
> > >  +                      h->root.root.string);
> > >  +                   sym->st_value = 0;
> 
> BTW, I will be removing this warning message as it triggers on
> _Jv_RegisterClasses.  Also, I managed to confuse myself over when the
> problems happens..  It isn't non-pic code, which is hopelessly broken
> even with this change, but pic code. 

Yes, it is a weak and hidden with shared library. How do you make
the pointer to a weak hidden symbol in a shared library to NULL
at the runtime? Do you modify the instruction addressing mode?
Right now, I got

bash-3.2$ cat x.c
extern void foo() __attribute__((weak,visibility("hidden")));
extern int puts( char const* );
int main()
{
        foo ? foo() : puts( "foo == null, skipped." );
        return 0;
}
bash-3.2$ /usr/gcc-4.4/bin/gcc -fPIE -pie x.c -m32
bash-3.2$ ./a.out 
Segmentation fault
bash-3.2$ /usr/gcc-4.4/bin/gcc -fPIE -pie x.c -m32 -c
bash-3.2$ readelf -s x.o | grep foo
    13: 00000000     0 NOTYPE  WEAK   HIDDEN  UND foo
bash-3.2$ 

on ia32. 



H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]