This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
MIPS/ELF linker
- To: binutils@sourceware.cygnus.com, Tim Hockin <thockin@cobaltnet.com>
- Subject: MIPS/ELF linker
- From: Ralf Baechle <ralf@gnu.org>
- Date: Sat, 31 Jul 1999 23:31:50 +0200
Starting to play with the new MIPS backend from CVS:
[ralf@lappi binutils]$ cat x.s
.text
.globl __start
.weak hurz
__start:
la $2,hurz
[ralf@lappi binutils]$ mips-linux-as -O3 -KPIC -o x.o x.s
[ralf@lappi binutils]$ mips-linux-ld -o x x.o
x.o(.text+0x0): undefined reference to `hurz'
mips-linux-ld: x.o: .text+0x0: jump to stub routine which is not jal
mips-linux-ld: final link failed: Bad value
[ralf@lappi binutils]$
Misshandling error the weak undefined reference prevents any linking
against GNU libc since crti.o has a weak undefined reference against
__gmon_start__. A fix for elf32-mips.c is appended below.
The ``jump to stub routine which is not jal'' error message which is
obviously bogus as well is caused by mips_elf_calculate_relocation
returning without setting *require_jalxp to a defined value. A patch
to initialize the variable at the beginning of the function is also
part of the elf32-mips.c patch below.
A third bug is triggered by attempting to link an arbitrary program like
``main(){}'' against glibc 2.0. This results in a large number of
/usr/bin/mips-linux-ld: not enough GOT space for local GOT entries
messages. Obviously the calculation of the GOT size is wrong, but I'm
not yet shure what's the problem, so I just report this without a fix.
Bug #4:
[ralf@lappi bfd]$ cat y.s
.text
foo: la $2,foo
[ralf@lappi bfd]$ mips-linux-as -O3 -KPIC -o y.o y.s
[ralf@lappi bfd]$ mips-linux-ld -o y y.o
Segmentation fault (core dumped)
[ralf@lappi bfd]$
This is caused by g->global_gotsym in elf32-mips.c:7896
i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx;
being NULL; I also don't have a fix for this one.
Ralf
--- elf32-mips.c-cygnus Sat Jul 31 12:23:43 1999
+++ elf32-mips.c Sat Jul 31 23:02:33 1999
@@ -5791,6 +5791,9 @@
/* Assume that there will be no overflow. */
overflowed_p = false;
+ /* Assume no jalx is required */
+ *require_jalxp = false;
+
/* Figure out whether or not the symbol is local, and get the offset
used in the array of hash table entries. */
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
@@ -5870,6 +5873,12 @@
else
symbol = h->root.root.u.def.value;
}
+ else if ((h->root.root.type == bfd_link_hash_undefweak)
+ || (info->shared && !info->symbolic && !info->no_undefined))
+ {
+ sec = bfd_und_section_ptr;
+ symbol = 0;
+ }
else
{
(*info->callbacks->undefined_symbol)