This is the mail archive of the binutils@sources.redhat.com 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: Fix ELF/MIPS SHF_MERGE (Re: binutils is broken on ELF/MIPS)


On Mon, Jun 03, 2002 at 11:57:03AM -0700, H . J . Lu wrote:
> On Mon, Jun 03, 2002 at 10:41:31AM -0700, H . J . Lu wrote:
> > 
> > Jakub, I believe your patch
> > 
> > http://sources.redhat.com/ml/binutils/2001-11/msg00580.html
> > 
> > breaks ELF/MIPS since it didn't modify ELF/MIPS to support relocating
> > STT_SECTION sym in SHF_MERGE section. As the result, the ELF/MIPS
> > linker generates incorrect debug information. Could you please look
> > into it?
> > 
> > BTW, I don't know if ELF/MIPS is the only broken target.
> > 
> > Thanks.
> > 
> > 
> 
> This patch makes gdb 5.2 happy. However, I have no ideas if it is
> correct. Could someone please take a look?
> 

My last patch is incorrect since SEC is used later, which may be
discarded due to merge. Could somene please take a closer look at
this and make sure it is 100% correct?

Thanks.


H.J.
---
2002-06-04  H.J. Lu <hjl@gnu.org>

	* elfxx-mips.c (mips_elf_calculate_relocation): Call
	_bfd_elf_rel_local_sym for STT_SECTION relocations against
	the SEC_MERGE section.

--- bfd/elfxx-mips.c.merge	Sat May 25 17:39:36 2002
+++ bfd/elfxx-mips.c	Tue Jun  4 16:10:26 2002
@@ -2083,8 +2083,16 @@ mips_elf_calculate_relocation (abfd, inp
       sec = local_sections[r_symndx];
 
       symbol = sec->output_section->vma + sec->output_offset;
-      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION
+	  || (sec->flags & SEC_MERGE))
 	symbol += sym->st_value;
+      if ((sec->flags & SEC_MERGE)
+	  && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	{
+	  addend = _bfd_elf_rel_local_sym (abfd, sym, &sec, addend);
+	  addend -= symbol;
+	  addend += sec->output_section->vma + sec->output_offset;
+	}
 
       /* MIPS16 text labels should be treated as odd.  */
       if (sym->st_other == STO_MIPS16)


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