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]

PATCH: ld/4208: `final link failed: Bad value' when building Linux MIPS kernels.


In PR 4208, MIPS Linker doesn't give a clue when something goes
wrong:

./ld --oformat elf32-tradlittlemips -r -o foo.o drivers/mtd/mtdcore.o drivers/mtd/mtdpart.o drivers/mtd/mtdchar.o drivers/mtd/mtdblock.o drivers/mtd/mtd_blkdevs.o drivers/mtd/chips/built-in.o drivers/mtd/maps/built-in.o drivers/mtd/devices/built-in.o drivers/mtd/nand/built-in.o
./ld: final link failed: Bad value

The problem is there is a missing matching LO16 relocation for HI16
relocation in drivers/mtd/mtd_blkdevs.o. I don't know if it is valid
or not. Some MIPS people should take a look.

This patch just gives a clue:

./ld --oformat elf32-tradlittlemips -r -o foo.o drivers/mtd/mtdcore.o drivers/mtd/mtdpart.o drivers/mtd/mtdchar.o drivers/mtd/mtdblock.o drivers/mtd/mtd_blkdevs.o drivers/mtd/chips/built-in.o drivers/mtd/maps/built-in.o drivers/mtd/devices/built-in.o drivers/mtd/nand/built-in.o
./ld: drivers/mtd/mtd_blkdevs.o: Can't find matching LO16 reloc against `$LC1' for R_MIPS_HI16 at 0xb88 in section `.text'
./ld: final link failed: Bad value



H.J.
---
2003-03-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/4208
	* elfxx-mips.c (_bfd_mips_elf_relocate_section): Report missing
	matching LO16 relocation for HI16 relocation.
	
--- bfd/elfxx-mips.c.lo16	2007-03-07 06:16:57.000000000 -0800
+++ bfd/elfxx-mips.c	2007-03-19 21:25:03.000000000 -0700
@@ -7756,6 +7756,8 @@ _bfd_mips_elf_relocate_section (bfd *out
       const char *msg;
       unsigned long r_symndx;
       asection *sec;
+      Elf_Internal_Shdr *symtab_hdr;
+      struct elf_link_hash_entry *h;
 
       /* Find the relocation howto for this relocation.  */
       howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, r_type,
@@ -7765,15 +7767,16 @@ _bfd_mips_elf_relocate_section (bfd *out
 					    rel - relocs)));
 
       r_symndx = ELF_R_SYM (input_bfd, rel->r_info);
+      symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
       if (mips_elf_local_relocation_p (input_bfd, rel, local_sections, FALSE))
-	sec = local_sections[r_symndx];
+	{
+	  sec = local_sections[r_symndx];
+	  h = NULL;
+	}
       else
 	{
-	  Elf_Internal_Shdr *symtab_hdr;
 	  unsigned long extsymoff;
-	  struct elf_link_hash_entry *h;
 
-	  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
 	  extsymoff = 0;
 	  if (!elf_bad_symtab (input_bfd))
 	    extsymoff = symtab_hdr->sh_info;
@@ -7885,7 +7888,21 @@ _bfd_mips_elf_relocate_section (bfd *out
 							      lo16_type,
 							      rel, relend);
 		  if (lo16_relocation == NULL)
-		    return FALSE;
+		    {
+		      const char *name;
+
+		      if (h)
+			name = h->root.root.string;
+		      else
+			name = bfd_elf_sym_name (input_bfd, symtab_hdr,
+						 local_syms + r_symndx,
+						 sec);
+		      (*_bfd_error_handler)
+			(_("%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"),
+			 input_bfd, input_section, name, howto->name,
+			 rel->r_offset);
+		      return FALSE;
+		    }
 
 		  lo16_location = contents + lo16_relocation->r_offset;
 


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