linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Segfaults in powerpc ld (binutils-2.9.1-19a)
@ 1999-03-05 19:04 harry eaton
  1999-03-05 19:11 ` Gary Thomas
  1999-03-07  0:52 ` H.J. Lu
  0 siblings, 2 replies; 4+ messages in thread
From: harry eaton @ 1999-03-05 19:04 UTC (permalink / raw)
  To: egcs, linuxppc-dev


I'm getting seg-faults in ld when I try to compile twin on a powerpc
linux system.  I'm using binutils-2.9.1-19a
and egcs-1.1-1c.

gcc is invoked with these arguments:


-Wall -fwritable-strings -fPIC -shared  -Wl,-Bsymbolic

What specifically is happening is this:
 on line 2856 of bfd/elf32-ppc.c (of binutls of course) the segfault
occurs.

rel->r_info is R_PPC_REL24
info->symbolic is true.
the name of the section:  h->root.u.def.section is ".text"
h->root.u.def.section->output_section is NULL !!!!

The NULL is the problem since it is de-referenced.

I added a test for this NULL, and just used a break
to stop the segfault.  That stops the segfault but
seems to just lose the symbol?  (Later stages of the
make complain about missing symbols during
linking.)  I also added some statements to print
when the this line is encountered and the output_section
is not 0.  I've compiled a few other things with it
configured this way, and the print is never triggered.
It seems like this particular relocation situation is
very seldom encountered, so the bug may have been
lurking for a while.

I have to admit that I don't know enough about the
linker to figure out what's going on.

the twin source consistently causes this problem,
but I have not been able to make  a small example.

Ideas?

harry




[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Segfaults in powerpc ld (binutils-2.9.1-19a)
  1999-03-05 19:04 Segfaults in powerpc ld (binutils-2.9.1-19a) harry eaton
@ 1999-03-05 19:11 ` Gary Thomas
  1999-03-07  0:52 ` H.J. Lu
  1 sibling, 0 replies; 4+ messages in thread
From: Gary Thomas @ 1999-03-05 19:11 UTC (permalink / raw)
  To: harry eaton; +Cc: linuxppc-dev, egcs


This is a known (at least to me) BFD problem.  I believe that it would
be fixed by applying this patch:

 Index: elf32-ppc.c
 ===================================================================
 RCS file: bfd/elf32-ppc.c,v
 retrieving revision 1.86
 diff -p -r1.86 elf32-ppc.c
 *** elf32-ppc.c        1998/08/02 10:22:31     1.86
 --- elf32-ppc.c        1999/02/03 16:09:54
 *************** ppc_elf_relocate_section (output_bfd, in
 *** 2753,2760 ****
   
     local_got_offsets = elf_local_got_offsets (input_bfd);
   
 !   splt = bfd_get_section_by_name (dynobj, ".plt");
 !   sgot = bfd_get_section_by_name (dynobj, ".got");
   
     for (; rel < relend; rel++)
       {
 --- 2753,2763 ----
   
     local_got_offsets = elf_local_got_offsets (input_bfd);
   
 !   if (dynobj)
 !     {
 !       splt = bfd_get_section_by_name (dynobj, ".plt");
 !       sgot = bfd_get_section_by_name (dynobj, ".got");
 !     }
   
     for (; rel < relend; rel++)
       {

Can you rebuild the BINUTILS with this patch and let me know if it solves
your problem?

On 05-Mar-99 harry eaton wrote:
> I'm getting seg-faults in ld when I try to compile twin on a powerpc
> linux system.  I'm using binutils-2.9.1-19a
> and egcs-1.1-1c.
> 
> gcc is invoked with these arguments:
> 
> 
> -Wall -fwritable-strings -fPIC -shared  -Wl,-Bsymbolic
> 
> What specifically is happening is this:
>  on line 2856 of bfd/elf32-ppc.c (of binutls of course) the segfault
> occurs.
> 
> rel->r_info is R_PPC_REL24
> info->symbolic is true.
> the name of the section:  h->root.u.def.section is ".text"
> h->root.u.def.section->output_section is NULL !!!!
> 
> The NULL is the problem since it is de-referenced.
> 
> I added a test for this NULL, and just used a break
> to stop the segfault.  That stops the segfault but
> seems to just lose the symbol?  (Later stages of the
> make complain about missing symbols during
> linking.)  I also added some statements to print
> when the this line is encountered and the output_section
> is not 0.  I've compiled a few other things with it
> configured this way, and the print is never triggered.
> It seems like this particular relocation situation is
> very seldom encountered, so the bug may have been
> lurking for a while.
> 
> I have to admit that I don't know enough about the
> linker to figure out what's going on.
> 
> the twin source consistently causes this problem,
> but I have not been able to make  a small example.
> 
> Ideas?
> 
> harry
> 

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Segfaults in powerpc ld (binutils-2.9.1-19a)
  1999-03-05 19:04 Segfaults in powerpc ld (binutils-2.9.1-19a) harry eaton
  1999-03-05 19:11 ` Gary Thomas
@ 1999-03-07  0:52 ` H.J. Lu
  1 sibling, 0 replies; 4+ messages in thread
From: H.J. Lu @ 1999-03-07  0:52 UTC (permalink / raw)
  To: harry eaton; +Cc: egcs, linuxppc-dev


> 
> I'm getting seg-faults in ld when I try to compile twin on a powerpc
> linux system.  I'm using binutils-2.9.1-19a
> and egcs-1.1-1c.
> 

Please try binutils 2.9.1.0.22.


H.J.

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Segfaults in powerpc ld (binutils-2.9.1-19a)
       [not found] <XFMail.990305211648.gdt@linuxppc.org>
@ 1999-03-08 21:53 ` harry eaton
  0 siblings, 0 replies; 4+ messages in thread
From: harry eaton @ 1999-03-08 21:53 UTC (permalink / raw)
  To: Gary Thomas; +Cc: linuxppc-dev


Gary Thomas wrote:

> On 05-Mar-99 harry eaton wrote:
> > Gary,
> >
> > I'm not sure what's going on.  My source was derived from
> > binutils-2.9.1-19a.src.rpm from linuxppc.org's
> > which was unpacked with
> > rpm -iv ../SRPMS/binutils-2.9.1-19a.src.rpm
> > rpm -bc bintuils.spec
> >
> > but the file doesn't match yours!  It looks most similar at line 2665
> > which originally looked like:
> > .. snip.

> Your source seems to have another hundred lines
> > that mine doesn't!!!
> > Of course I found this segfault problem with the linker from the binary
> > rpm.
> >
> > More ideas?
> >
>
> The patch came from code I have which is slightly different than the
> released binutils code, sorry.  If I have time, I'll try and give you
> a more complete patch.
>
> In the meantime, you might try just not using -Bsymbolic which seems
> to be the root of the problem.  If you're building a shared library with
> -fPIC, I don't think it's necessary.

I tried removing the -Bsymbolic and indeed that stopped the segfaults.
However the resulting files didn't work.  In particular when calling one of
the shared library routines, the caller puts the first argument into R3, but
the linker blows away R3 and the library uses R28 (or maybe the stack) to
retrieve its first argument (at least that's what gdb shows and it seems to
agree with the code behavior)  It's all pretty strange to me; I'll have to
look at the ABI again to get a sense of what's going on.  If the args were
supposed to be copied to the stack, they didn't make it correctly.  I also
tried the binutils-2.9.1-19b that you (Gary) made available recently - same
segfault problem when linking with -Bsymbolic.

harry




[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-03-08 21:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-03-05 19:04 Segfaults in powerpc ld (binutils-2.9.1-19a) harry eaton
1999-03-05 19:11 ` Gary Thomas
1999-03-07  0:52 ` H.J. Lu
     [not found] <XFMail.990305211648.gdt@linuxppc.org>
1999-03-08 21:53 ` harry eaton

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 NNTP newsgroup(s).