When building a Linux MIPS kernel, a link failure occured while building one of
the driver subsystems in a Linux 2.6.12 tree. The versions of the tools to
create the cross compiler were:
binutils-2.17.50.0.12
gcc-4.2-20070131
linux-headers-2.6.12
A snippet of the output is below:
LD drivers/mtd/maps/built-in.o
LD drivers/mtd/nand/built-in.o
LD drivers/mtd/built-in.o
mipsel-linux-uclibc-ld: final link failed: Bad value
make[1]: *** [drivers/mtd/built-in.o] Error 1
make: *** [_module_drivers/mtd] Error 2
Using the release version of binutils-2.17 works fine and does not
produce the error above. However, binutils-HEAD out of today's CVS
and all of H.J. Lu's development releases > 2.17.50.0.3 will produce
the error. The regression appeared in binutils-2.17.50.0.4 and still
exists. The first patch tried that worked was:
--- binutils-2.17.50.0.12/bfd/elfxx-mips.c
+++ binutils-2.17.50.0.12-patched/bfd/elfxx-mips.c
@@ -3603,12 +3603,9 @@
const Elf_Internal_Rela *relocation,
const Elf_Internal_Rela *relend)
{
- unsigned long r_symndx = ELF_R_SYM (abfd, relocation->r_info);
-
while (relocation < relend)
{
- if (ELF_R_TYPE (abfd, relocation->r_info) == r_type
- && ELF_R_SYM (abfd, relocation->r_info) == r_symndx)
+ if (ELF_R_TYPE (abfd, relocation->r_info) == r_type)
return relocation;
++relocation;
I applied to binutils-HEAD and was then able to build a valid Linux/MIPS
kernel and applications. It was then suggested by Thiemo to not throw an
error and instead just return NULL. The final patch that worked properly
was:
--- binutils-2.17.50.0.12/bfd/elfxx-mips.c
+++ binutils-2.17.50.0.12-patched/bfd/elfxx-mips.c
@@ -3603,19 +3603,15 @@
const Elf_Internal_Rela *relocation,
const Elf_Internal_Rela *relend)
{
- unsigned long r_symndx = ELF_R_SYM (abfd, relocation->r_info);
-
while (relocation < relend)
{
- if (ELF_R_TYPE (abfd, relocation->r_info) == r_type
- && ELF_R_SYM (abfd, relocation->r_info) == r_symndx)
+ if (ELF_R_TYPE (abfd, relocation->r_info) == r_type)
return relocation;
++relocation;
}
/* We didn't find it. */
- bfd_set_error (bfd_error_bad_value);
return NULL;
}
I was able to create a complete cross toolchain, build a Linux/MIPS kernel and a
complete root filesystem with not issues after applying the above patch.
--
Summary: 'final link failed: Bad value' when building Linux MIPS
kernels.
Product: binutils
Version: 2.18 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: binutils
AssignedTo: unassigned at sources dot redhat dot com
ReportedBy: sjhill at realitydiluted dot com
CC: bug-binutils at gnu dot org
GCC build triplet: mipsel-linux
GCC host triplet: mipsel-linux
GCC target triplet: mipsel-linux
http://sourceware.org/bugzilla/show_bug.cgi?id=4208
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
_______________________________________________
bug-binutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-binutils