public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
@ 2000-06-19  7:55 Maciej W. Rozycki
  2000-06-19 17:10 ` Alan Modra
  2000-06-19 17:41 ` Ulf Carlsson
  0 siblings, 2 replies; 13+ messages in thread
From: Maciej W. Rozycki @ 2000-06-19  7:55 UTC (permalink / raw)
  To: binutils, Ulf Carlsson

Hi,

 It looks like there is a problem when bfd has to emit a R_MIPS_REL32
relocation for an ELF executable (not a shared object) and the relocation
is against a versioned symbol.  The generic
_bfd_elf_link_hash_copy_indirect () function does not copy MIPS-specific
relocation data and as a result space for .rel.dyn's contents is not
allocated.  This leads to a segfault when
mips_elf_create_dynamic_relocation () is called. 

 The following patch seems to work for me -- I tested it successfully
linking problematic object files against glibc 2.1.90 and running
resulting binaries on a mipsel-linux system.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

Mon Jun 19 05:09:21 2000  Maciej W. Rozycki <macro@ds2.pg.gda.pl>

	* elf32-mips.c (_bfd_mips_elf_copy_indirect_symbol): New function.
	(elf_backend_copy_indirect_symbol): Map to the new function.
	Fix typos in comments.

diff -u --recursive --new-file binutils.macro/bfd/elf32-mips.c binutils/bfd/elf32-mips.c
--- binutils.macro/bfd/elf32-mips.c	Wed May 24 14:40:42 2000
+++ binutils/bfd/elf32-mips.c	Mon Jun 19 05:09:21 2000
@@ -5581,7 +5581,7 @@
 
 /* Create a rel.dyn relocation for the dynamic linker to resolve.  REL
    is the original relocation, which is now being transformed into a
-   dyanmic relocation.  The ADDENDP is adjusted if necessary; the
+   dynamic relocation.  The ADDENDP is adjusted if necessary; the
    caller should store the result in place of the original addend.  */
 
 static boolean
@@ -5634,7 +5634,7 @@
 	skip = true;
     }
 
-  /* If we've decided to skip this relocation, just output an emtpy
+  /* If we've decided to skip this relocation, just output an empty
      record.  Note that R_MIPS_NONE == 0, so that this call to memset
      is a way of setting R_TYPE to R_MIPS_NONE.  */
   if (skip)
@@ -7750,6 +7750,26 @@
   return true;
 }
 
+/* Copy data from a MIPS ELF indirect symbol to its direct symbol,
+   hiding the old indirect symbol.  Process additional relocation
+   information.  */
+
+void
+_bfd_mips_elf_copy_indirect_symbol (dir, ind)
+     struct elf_link_hash_entry *dir, *ind;
+{
+  struct mips_elf_link_hash_entry *dirmips, *indmips;
+
+  _bfd_elf_link_hash_copy_indirect (dir, ind);
+
+  dirmips = (struct mips_elf_link_hash_entry *) dir;
+  indmips = (struct mips_elf_link_hash_entry *) ind;
+  dirmips->possibly_dynamic_relocs += indmips->possibly_dynamic_relocs;
+  if (dirmips->min_dyn_reloc_index == 0
+      || (indmips->min_dyn_reloc_index != 0
+          && indmips->min_dyn_reloc_index < dirmips->min_dyn_reloc_index))
+    dirmips->min_dyn_reloc_index = indmips->min_dyn_reloc_index;
+}
 
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
@@ -9029,6 +9049,9 @@
 
 #define elf_backend_got_header_size	(4*MIPS_RESERVED_GOTNO)
 #define elf_backend_plt_header_size	0
+
+#define elf_backend_copy_indirect_symbol \
+					_bfd_mips_elf_copy_indirect_symbol
 
 #define bfd_elf32_bfd_is_local_label_name \
 					mips_elf_is_local_label_name

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-19  7:55 bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly Maciej W. Rozycki
@ 2000-06-19 17:10 ` Alan Modra
  2000-06-20  6:10   ` Maciej W. Rozycki
  2000-06-19 17:41 ` Ulf Carlsson
  1 sibling, 1 reply; 13+ messages in thread
From: Alan Modra @ 2000-06-19 17:10 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils, Ulf Carlsson

On Mon, 19 Jun 2000, Maciej W. Rozycki wrote:

>	* elf32-mips.c (_bfd_mips_elf_copy_indirect_symbol): New function.
>	(elf_backend_copy_indirect_symbol): Map to the new function.
>	Fix typos in comments.

What you're trying to achieve looks good to me, but why can't you just
copy possibly_dynamic_relocs and min_dyn_reloc_index across?  Is it really
necessary to merge these fields?  I know the generic code does this sort
of thing, but from my cursory inspection of elf32-mips.c, it seems like
the mips back-end will only update these values for the direct symbol.

Hmm, is it necessary to copy the fn_stub, need_fn_stub, call_stub and
call_fp_stub fields too?

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.



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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-19  7:55 bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly Maciej W. Rozycki
  2000-06-19 17:10 ` Alan Modra
@ 2000-06-19 17:41 ` Ulf Carlsson
  2000-06-20  5:57   ` Maciej W. Rozycki
  1 sibling, 1 reply; 13+ messages in thread
From: Ulf Carlsson @ 2000-06-19 17:41 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

Hi Maciej,

 > 	* elf32-mips.c (_bfd_mips_elf_copy_indirect_symbol): New function.
 > 	(elf_backend_copy_indirect_symbol): Map to the new function.
 > 	Fix typos in comments.

Thanks for the patch.  Do you have a testcase for this as well?  I do
have ld crashes when I compile with gcc 2.96.  It seems like it could
be the same problem since it doesn't happen with shared libraries, but
with executables.  However, this patch doesn't solve it.  I'll look at
it myself now.

Ulf

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-19 17:41 ` Ulf Carlsson
@ 2000-06-20  5:57   ` Maciej W. Rozycki
  2000-06-20  9:35     ` Ulf Carlsson
  0 siblings, 1 reply; 13+ messages in thread
From: Maciej W. Rozycki @ 2000-06-20  5:57 UTC (permalink / raw)
  To: Ulf Carlsson; +Cc: binutils

On Mon, 19 Jun 2000, Ulf Carlsson wrote:

> Thanks for the patch.  Do you have a testcase for this as well?  I do
> have ld crashes when I compile with gcc 2.96.  It seems like it could
> be the same problem since it doesn't happen with shared libraries, but
> with executables.  However, this patch doesn't solve it.  I'll look at
> it myself now.

 Basically any reference from executable's .data section to a .text object
defined within a shared library.  For example:

#include <stdlib.h>
void (*myfree)(void *) = free;

int main(void)
{
	return 0;
}

 I use gcc 2.95.2, so your problem might actually be different.

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-19 17:10 ` Alan Modra
@ 2000-06-20  6:10   ` Maciej W. Rozycki
  2000-06-20  6:58     ` Alan Modra
  0 siblings, 1 reply; 13+ messages in thread
From: Maciej W. Rozycki @ 2000-06-20  6:10 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, Ulf Carlsson

On Tue, 20 Jun 2000, Alan Modra wrote:

> >	* elf32-mips.c (_bfd_mips_elf_copy_indirect_symbol): New function.
> >	(elf_backend_copy_indirect_symbol): Map to the new function.
> >	Fix typos in comments.
> 
> What you're trying to achieve looks good to me, but why can't you just
> copy possibly_dynamic_relocs and min_dyn_reloc_index across?  Is it really
> necessary to merge these fields?  I know the generic code does this sort

 It won't work.  These fields have their semantics which I am preserving
here and if you have two relocations against the same symbol that come
from separate files, then the last one will override previous ones if a
plain copy is performed. 

> of thing, but from my cursory inspection of elf32-mips.c, it seems like
> the mips back-end will only update these values for the direct symbol.

 No, it updates them per relocation.  That's much before the symbol is
found and resolved in a shared object.

 I tried copying first, and it didn't work.  A hardware watchpoint
revealed that for a simple test case (void (*myfree)(void *) = free; see
also my other mail) is initially 0, then set to 1 (because of myfree's
relocation) and then to 0 again due to some crt clean-up code.  Summing
these up achieves the desired effect.

 I haven't tested min_dyn_reloc_index, actually, but given what I observed
I decided to keep it consistent as well. 

> Hmm, is it necessary to copy the fn_stub, need_fn_stub, call_stub and
> call_fp_stub fields too?

 No idea how to perform this -- it looks like they are of interest of
embedded people (they are related to MIPS16), so let them speak for
themselves.  I'm not sure whether they use weak symbols, though...

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20  6:10   ` Maciej W. Rozycki
@ 2000-06-20  6:58     ` Alan Modra
  2000-06-20  7:24       ` Maciej W. Rozycki
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Modra @ 2000-06-20  6:58 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils, Ulf Carlsson

On Tue, 20 Jun 2000, Maciej W. Rozycki wrote:

>  I tried copying first, and it didn't work.  A hardware watchpoint

OK, please check in your patch.  Thanks for fixing this problem (and for
correcting the typos)

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20  6:58     ` Alan Modra
@ 2000-06-20  7:24       ` Maciej W. Rozycki
  2000-06-20  9:39         ` Ulf Carlsson
  0 siblings, 1 reply; 13+ messages in thread
From: Maciej W. Rozycki @ 2000-06-20  7:24 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, Ulf Carlsson

On Tue, 20 Jun 2000, Alan Modra wrote:

> OK, please check in your patch.  Thanks for fixing this problem (and for
> correcting the typos)

 Could you please do this for me?  I don't think I can check in myself. 

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20  5:57   ` Maciej W. Rozycki
@ 2000-06-20  9:35     ` Ulf Carlsson
  2000-06-20 10:03       ` Maciej W. Rozycki
  0 siblings, 1 reply; 13+ messages in thread
From: Ulf Carlsson @ 2000-06-20  9:35 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

Hi Maciej,

 > > Thanks for the patch.  Do you have a testcase for this as well?  I do
 > > have ld crashes when I compile with gcc 2.96.  It seems like it could
 > > be the same problem since it doesn't happen with shared libraries, but
 > > with executables.  However, this patch doesn't solve it.  I'll look at
 > > it myself now.
 > 
 >  Basically any reference from executable's .data section to a .text object
 > defined within a shared library.  For example:
 > 
 > #include <stdlib.h>
 > void (*myfree)(void *) = free;
 > 
 > int main(void)
 > {
 > 	return 0;
 > }
 > 
 >  I use gcc 2.95.2, so your problem might actually be different.

I tried this on both 2.91.66 and 2.96 that I have installed and I
didn't experience any problems.

Ulf

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20  7:24       ` Maciej W. Rozycki
@ 2000-06-20  9:39         ` Ulf Carlsson
  0 siblings, 0 replies; 13+ messages in thread
From: Ulf Carlsson @ 2000-06-20  9:39 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

 > > OK, please check in your patch.  Thanks for fixing this problem (and for
 > > correcting the typos)
 > 
 >  Could you please do this for me?  I don't think I can check in myself. 
 
Applied.

Ulf

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20  9:35     ` Ulf Carlsson
@ 2000-06-20 10:03       ` Maciej W. Rozycki
  2000-06-20 10:09         ` Ulf Carlsson
  2000-06-20 10:13         ` Ulf Carlsson
  0 siblings, 2 replies; 13+ messages in thread
From: Maciej W. Rozycki @ 2000-06-20 10:03 UTC (permalink / raw)
  To: Ulf Carlsson; +Cc: binutils

Hi Ulf,

>  >  Basically any reference from executable's .data section to a .text object
>  > defined within a shared library.  For example:
>  > 
>  > #include <stdlib.h>
>  > void (*myfree)(void *) = free;
>  > 
>  > int main(void)
>  > {
>  > 	return 0;
>  > }
>  > 
>  >  I use gcc 2.95.2, so your problem might actually be different.
> 
> I tried this on both 2.91.66 and 2.96 that I have installed and I
> didn't experience any problems.

 How does `objdump -r' on your relocateable look like?  I've seen this
happening for R_MIPS_32 relocations in .data section that refer to a
versioned symbol in a shared object upon linking.

 OK, try to supply:

	.data
	.globl	myfree
myfree:
	.word	free
	.text
	.globl	main
main:

to gas and then link it instead.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20 10:03       ` Maciej W. Rozycki
@ 2000-06-20 10:09         ` Ulf Carlsson
  2000-06-21  5:06           ` Maciej W. Rozycki
  2000-06-20 10:13         ` Ulf Carlsson
  1 sibling, 1 reply; 13+ messages in thread
From: Ulf Carlsson @ 2000-06-20 10:09 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

 >  How does `objdump -r' on your relocateable look like?  I've seen this
 > happening for R_MIPS_32 relocations in .data section that refer to a
 > versioned symbol in a shared object upon linking.
 > 
 >  OK, try to supply:
 > 
 > 	.data
 > 	.globl	myfree
 > myfree:
 > 	.word	free
 > 	.text
 > 	.globl	main
 > main:
 > 
 > to gas and then link it instead.

It still works fine.

Ulf

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20 10:03       ` Maciej W. Rozycki
  2000-06-20 10:09         ` Ulf Carlsson
@ 2000-06-20 10:13         ` Ulf Carlsson
  1 sibling, 0 replies; 13+ messages in thread
From: Ulf Carlsson @ 2000-06-20 10:13 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

 >  How does `objdump -r' on your relocateable look like?  I've seen this
 > happening for R_MIPS_32 relocations in .data section that refer to a
 > versioned symbol in a shared object upon linking.
 > 
 >  OK, try to supply:
 > 
 > 	.data
 > 	.globl	myfree
 > myfree:
 > 	.word	free
 > 	.text
 > 	.globl	main
 > main:
 > 
 > to gas and then link it instead.
 
I had another nasty problem with gcc 2.96 by the way that caused ld to
crash at exactly the same place.  I've added an assertion failure
there now.  For me the offending object file was in libgcc.

Ulf

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

* Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly
  2000-06-20 10:09         ` Ulf Carlsson
@ 2000-06-21  5:06           ` Maciej W. Rozycki
  0 siblings, 0 replies; 13+ messages in thread
From: Maciej W. Rozycki @ 2000-06-21  5:06 UTC (permalink / raw)
  To: Ulf Carlsson; +Cc: binutils

On Tue, 20 Jun 2000, Ulf Carlsson wrote:

> It still works fine.

 Weird.  I took today's binutils, reverted my fix and tried to link the
following program:

reloc.c:

#include <stdio.h>
#include <stdlib.h>

void (*myfree)(void *) = free;

int main(void)
{
	fprintf(stderr, "%p\n", myfree);
	fprintf(stderr, "%p\n", free);
	free(0);
	myfree(0);

	return 0;
}

 Then:

$ mipsel-linux-gcc -Bbinutils/usr/mipsel-linux/bin/ -v -pipe -c reloc.c
Reading specs from /usr/lib/gcc-lib/mipsel-linux/2.95.3/specs
gcc version 2.95.3 19991030 (prerelease)
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/cpp -lang-c -v -isystem binutils/usr/mipsel-linux/bin/include -D__GNUC__=2 -D__GNUC_MINOR__=95 -DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips -DR3000 -D_R3000 -Dlinux -D__ELF__ -D__PIC__ -D__pic__ -D__MIPSEL__ -D_MIPSEL -D__unix__ -D__mips__ -D___mips__ -D__R3000__ -D_R3000 -D__linux__ -D__ELF__ -D__PIC__ -D__pic__ -D__MIPSEL -D__unix -D__mips -D___mips -D__R3000 -D__linux -Asystem(posix) -Acpu(mips) -Amachine(mips) -D__LANGUAGE_C -D_LANGUAGE_C -DLANGUAGE_C -D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D_MIPS_FPSET=32 -D_MIPS_ISA=_MIPS_ISA_MIPS1 -D_ABIN32=2 -D_MIPS_SIM=_ABIN32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 -U__mips -D__mips -U__mips64 reloc.c |
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/cc1 -quiet -dumpbase reloc.c -version -o - |
 binutils/usr/mipsel-linux/bin/as -v -KPIC -o reloc.o
GNU CPP version 2.95.3 19991030 (prerelease) (MIPSel GNU/Linux with ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/include
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/../../../../mipsel-linux/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/../../../../mipsel-linux/include/g++-3
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/../../../../mipsel-linux/sys-include
End of omitted list.
GNU assembler version 2.10.90 (mipsel-linux) using BFD version 2.10.90
GNU C version 2.95.3 19991030 (prerelease) (mipsel-linux) compiled by GNU C version 2.95.3 19991030 (prerelease).
$ binutils/usr/bin/mipsel-linux-objdump -rt reloc.o

reloc.o:     file format elf32-littlemips

SYMBOL TABLE:
0000000000000000 l    d  .text	0000000000000000 
0000000000000000 l    d  .data	0000000000000000 
0000000000000000 l    d  .bss	0000000000000000 
0000000000000000 l    d  .rodata	0000000000000000 
0000000000000000 l    d  .reginfo	0000000000000000 
0000000000000000 l    d  .mdebug	0000000000000000 
0000000000000000 l    d  .note	0000000000000000 
0000000000000000 l       .text	0000000000000000 gcc2_compiled.
0000000000000000 l       .text	0000000000000000 __gnu_compiled_c
0000000000000000 g     O .data	0000000000000004 myfree
0000000000000000         *UND*	0000000000000000 free
0000000000000000 g     F .text	0000000000000108 main
0000000000000000       O *UND*	0000000000000000 _gp_disp
0000000000000000         *UND*	0000000000000000 __main
0000000000000000         *UND*	0000000000000000 stderr
0000000000000000         *UND*	0000000000000000 fprintf


RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE 
0000000000000000 R_MIPS_HI16       _gp_disp
0000000000000004 R_MIPS_LO16       _gp_disp
0000000000000024 R_MIPS_GOT16      __main
000000000000003c R_MIPS_GOT16      stderr
0000000000000048 R_MIPS_GOT16      .rodata
0000000000000050 R_MIPS_LO16       .rodata
0000000000000054 R_MIPS_GOT16      .data
000000000000005c R_MIPS_LO16       .data
0000000000000064 R_MIPS_GOT16      fprintf
000000000000007c R_MIPS_GOT16      stderr
0000000000000088 R_MIPS_GOT16      .rodata
0000000000000090 R_MIPS_LO16       .rodata
0000000000000094 R_MIPS_GOT16      free
0000000000000098 R_MIPS_GOT16      fprintf
00000000000000b0 R_MIPS_GOT16      free
00000000000000c8 R_MIPS_GOT16      .data
00000000000000d0 R_MIPS_LO16       .data


RELOCATION RECORDS FOR [.data]:
OFFSET           TYPE              VALUE 
0000000000000000 R_MIPS_32         free

$ mipsel-linux-gcc -Bbinutils/usr/mipsel-linux/bin/ -v -Wl,--verbose -o reloc reloc.o
Reading specs from /usr/lib/gcc-lib/mipsel-linux/2.95.3/specs
gcc version 2.95.3 19991030 (prerelease)
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/collect2 -dynamic-linker /lib/ld.so.1 -o reloc /usr/mipsel-linux/lib/crt1.o /usr/mipsel-linux/lib/crti.o /usr/lib/gcc-lib/mipsel-linux/2.95.3/crtbegin.o -Lbinutils/usr/mipsel-linux/bin -L/usr/lib/gcc-lib/mipsel-linux/
2.95.3 -L/usr/mipsel-linux/lib --verbose reloc.o -lgcc -lc -lgcc /usr/lib/gcc-lib/mipsel-linux/2.95.3/crtend.o /usr/mipsel-linux/lib/crtn.o
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
GNU ld version 2.10.90 (with BFD 2.10.90)
  Supported emulations:
   elf32lsmip
   elf32bsmip
   mipslit
   mipsbig
using internal linker script:
==================================================
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
	      "elf32-littlemips")
OUTPUT_ARCH(mips)
ENTRY(__start)
 SEARCH_DIR(/usr/mipsel-linux/lib);
/* Do we need any of these for elf?
   __DYNAMIC = 0;    */
SECTIONS
{
  /* Read-only sections, merged into text segment: */
  . = 0x0400000 + SIZEOF_HEADERS;
  .interp     : { *(.interp) 	}
  .reginfo : { *(.reginfo) }
  .dynamic       : { *(.dynamic) }
  .hash          : { *(.hash)		}
  .dynsym        : { *(.dynsym)		}
  .dynstr        : { *(.dynstr)		}
  .gnu.version   : { *(.gnu.version)	}
  .gnu.version_d   : { *(.gnu.version_d)	}
  .gnu.version_r   : { *(.gnu.version_r)	}
  .rel.init      : { *(.rel.init)	}
  .rela.init     : { *(.rela.init)	}
  .rel.text      :
    {
      *(.rel.text)
      *(.rel.text.*)
      *(.rel.gnu.linkonce.t*)
    }
  .rela.text     :
    {
      *(.rela.text)
      *(.rela.text.*)
      *(.rela.gnu.linkonce.t*)
    }
  .rel.fini      : { *(.rel.fini)	}
  .rela.fini     : { *(.rela.fini)	}
  .rel.rodata    :
    {
      *(.rel.rodata)
      *(.rel.rodata.*)
      *(.rel.gnu.linkonce.r*)
    }
  .rela.rodata   :
    {
      *(.rela.rodata)
      *(.rela.rodata.*)
      *(.rela.gnu.linkonce.r*)
    }
  .rel.data      :
    {
      *(.rel.data)
      *(.rel.data.*)
      *(.rel.gnu.linkonce.d*)
    }
  .rela.data     :
    {
      *(.rela.data)
      *(.rela.data.*)
      *(.rela.gnu.linkonce.d*)
    }
  .rel.ctors     : { *(.rel.ctors)	}
  .rela.ctors    : { *(.rela.ctors)	}
  .rel.dtors     : { *(.rel.dtors)	}
  .rela.dtors    : { *(.rela.dtors)	}
  .rel.got       : { *(.rel.got)		}
  .rela.got      : { *(.rela.got)		}
  .rel.sdata     :
    {
      *(.rel.sdata)
      *(.rel.sdata.*)
      *(.rel.gnu.linkonce.s*)
    }
  .rela.sdata     :
    {
      *(.rela.sdata)
      *(.rela.sdata.*)
      *(.rela.gnu.linkonce.s*)
    }
  .rel.sbss      : { *(.rel.sbss)		}
  .rela.sbss     : { *(.rela.sbss)	}
  .rel.sdata2    : { *(.rel.sdata2)	}
  .rela.sdata2   : { *(.rela.sdata2)	}
  .rel.sbss2     : { *(.rel.sbss2)	}
  .rela.sbss2    : { *(.rela.sbss2)	}
  .rel.bss       : { *(.rel.bss)		}
  .rela.bss      : { *(.rela.bss)		}
  .rel.plt       : { *(.rel.plt)		}
  .rela.plt      : { *(.rela.plt)		}
  .init          : 
  { 
    KEEP (*(.init))
  } =0
  .plt      : { *(.plt)	}
  .text      :
  {
    _ftext = . ;
    *(.text)
    *(.text.*)
    *(.stub)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.gnu.linkonce.t*)
    *(.mips16.fn.*) *(.mips16.call.*)
  } =0
  .fini      :
  {
    KEEP (*(.fini))
  } =0
  PROVIDE (__etext = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  .rodata   : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) }
  .rodata1   : { *(.rodata1) }
  .sdata2   : { *(.sdata2) }
  .sbss2   : { *(.sbss2) }
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  */
  . = 0x10000000;
  .data    :
  {
    _fdata = . ;
    *(.data)
    *(.data.*)
    *(.gnu.linkonce.d*)
    SORT(CONSTRUCTORS)
  }
  .data1   : { *(.data1) }
  .eh_frame : { KEEP (*(.eh_frame)) }
  .gcc_except_table : { *(.gcc_except_table) }
  .ctors   : 
  {
    /* gcc uses crtbegin.o to find the start of
       the constructors, so we make sure it is
       first.  Because this is a wildcard, it
       doesn't matter if the user does not
       actually link against crtbegin.o; the
       linker won't look for a file to match a
       wildcard.  The wildcard also means that it
       doesn't matter which directory crtbegin.o
       is in.  */
    KEEP (*crtbegin.o(.ctors))
    /* We don't want to include the .ctor section from
       from the crtend.o file until after the sorted ctors.
       The .ctor section from the crtend file contains the
       end of ctors marker and it must be last */
    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  }
   .dtors         :
  {
    KEEP (*crtbegin.o(.dtors))
    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
    KEEP (*(SORT(.dtors.*)))
    KEEP (*(.dtors))
  }
  _gp = ALIGN(16) + 0x7ff0;
  .got		  : { *(.got.plt) *(.got) }
  /* We want the small data sections together, so single-instruction offsets
     can access them all, and initialized data all before uninitialized, so
     we can shorten the on-disk segment size.  */
  .sdata     : 
  {
    *(.sdata) 
    *(.sdata.*)
    *(.gnu.linkonce.s.*)
  }
  .lit8 : { *(.lit8) }
  .lit4 : { *(.lit4) }
  _edata = .;
  PROVIDE (edata = .);
  __bss_start = .;
  _fbss = .;
  .sbss      :
  {
    PROVIDE (__sbss_start = .);
    PROVIDE (___sbss_start = .);
    *(.dynsbss)
    *(.sbss)
    *(.sbss.*)
    *(.scommon)
    PROVIDE (__sbss_end = .);
    PROVIDE (___sbss_end = .);
  }
  .bss       :
  {
   *(.dynbss)
   *(.bss)
   *(.bss.*)
   *(COMMON)
   /* Align here to ensure that the .bss section occupies space up to
      _end.  Align after .bss to ensure correct alignment even if the
      .bss section disappears because there are no input sections.  */
   . = ALIGN(32 / 8);
  }
  . = ALIGN(32 / 8);
  _end = .;
  PROVIDE (end = .);
  /* Stabs debugging sections.  */
  .stab 0 : { *(.stab) }
  .stabstr 0 : { *(.stabstr) }
  .stab.excl 0 : { *(.stab.excl) }
  .stab.exclstr 0 : { *(.stab.exclstr) }
  .stab.index 0 : { *(.stab.index) }
  .stab.indexstr 0 : { *(.stab.indexstr) }
  .comment 0 : { *(.comment) }
  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
  /* These must appear regardless of  .  */
  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
}


==================================================
attempt to open /usr/mipsel-linux/lib/crt1.o succeeded
/usr/mipsel-linux/lib/crt1.o
attempt to open /usr/mipsel-linux/lib/crti.o succeeded
/usr/mipsel-linux/lib/crti.o
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/crtbegin.o succeeded
/usr/lib/gcc-lib/mipsel-linux/2.95.3/crtbegin.o
attempt to open reloc.o succeeded
reloc.o
attempt to open binutils/usr/mipsel-linux/bin/libgcc.so failed
attempt to open binutils/usr/mipsel-linux/bin/libgcc.a failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.so failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a succeeded
(/usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a)__main.o
(/usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a)_ctors.o
(/usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a)_exit.o
attempt to open binutils/usr/mipsel-linux/bin/libc.so failed
attempt to open binutils/usr/mipsel-linux/bin/libc.a failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libc.so failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libc.a failed
attempt to open /usr/mipsel-linux/lib/libc.so succeeded
opened script file /usr/mipsel-linux/lib/libc.so
attempt to open /usr/mipsel-linux/lib/libc.so.6 succeeded
/usr/mipsel-linux/lib/libc.so.6
attempt to open /usr/mipsel-linux/lib/libc_nonshared.a succeeded
attempt to open binutils/usr/mipsel-linux/bin/libgcc.so failed
attempt to open binutils/usr/mipsel-linux/bin/libgcc.binutils/usr/mipsel-linux/bin/ld: bfd assertion fail elf32-mips.c:5660
mipsel-linux-gcc: file path prefix `binutils/usr/mipsel-linux/bin/' never used

 Perfectly repeateble.  After reapplying of the patch ld works again.

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

end of thread, other threads:[~2000-06-21  5:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-19  7:55 bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly Maciej W. Rozycki
2000-06-19 17:10 ` Alan Modra
2000-06-20  6:10   ` Maciej W. Rozycki
2000-06-20  6:58     ` Alan Modra
2000-06-20  7:24       ` Maciej W. Rozycki
2000-06-20  9:39         ` Ulf Carlsson
2000-06-19 17:41 ` Ulf Carlsson
2000-06-20  5:57   ` Maciej W. Rozycki
2000-06-20  9:35     ` Ulf Carlsson
2000-06-20 10:03       ` Maciej W. Rozycki
2000-06-20 10:09         ` Ulf Carlsson
2000-06-21  5:06           ` Maciej W. Rozycki
2000-06-20 10:13         ` Ulf Carlsson

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).