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]

Re: Objcopy fix for relocation sections


On Thu, Aug 05, 2004 at 09:14:30AM -0400, Daniel Jacobowitz wrote:
> On Thu, Aug 05, 2004 at 06:57:04PM +0930, Alan Modra wrote:
> > On Tue, Aug 03, 2004 at 06:56:01PM -0400, Daniel Jacobowitz wrote:
> > > 	* elf.c (assign_file_positions_except_relocs): Revert unintended
> > > 	change from 2004-04-08.
> > 
> > Oops, please fix.
> > 
> > > 	(_bfd_elf_set_section_contents): Call
> > > 	_bfd_elf_assign_file_positions_for_relocs when starting output
> > > 	for executables and shared libraries.
> > 
> > Doesn't this break mips?  For example, I see an assignment to
> > rel_hdr->sh_size in mips_elf64_write_rel.  That size should determine
> > section placement, but you're doing the placement before
> > mips_elf64_write_rel is called.
> 
> Sparc64 does the same thing.  The problem looks plausible.  But I can't
> reproduce it; I can't get the linker to pass MIPS combined relocations
> through to a dynamic or executable module.  If I try to fake it using
> -q, some code that specifically takes care of the MIPS ugliness falls
> over in elflink.h (now in elflink.c, I'm looking at an older
> toolchain): in elf_bfd_final_link, esdi->rel_hdr.sh_entsize == 0.
> 
> So I have no way to check ;-)
> 
> If you're right, then I would like to go back to my first patch, the
> one which places each reloc section as _bfd_elf_set_section_contents
> is called on it.  That will change the behavior of objdump without
> changing the behavior of the assembler or linker.

Ping?  Here's the one in question.  I'd like to settle this.

-- 
Daniel Jacobowitz

2003-12-22  Daniel Jacobowitz  <drow@mvista.com>

	* elf.c (_bfd_elf_set_section_contents): If a relocation section
	does not have an offset, assign one.

Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.210
diff -u -p -r1.210 elf.c
--- elf.c	22 Nov 2003 10:45:44 -0000	1.210
+++ elf.c	22 Dec 2003 21:02:47 -0000
@@ -6109,6 +6109,17 @@ _bfd_elf_set_section_contents (bfd *abfd
     return FALSE;
 
   hdr = &elf_section_data (section)->this_hdr;
+
+  /* Unallocated relocation sections may not have a file offset yet.  Give
+     them one now.  */
+  if ((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
+      && hdr->sh_offset == -1)
+    {
+      file_ptr off = elf_tdata (abfd)->next_file_pos;
+      off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
+      elf_tdata (abfd)->next_file_pos = off;
+    }
+
   pos = hdr->sh_offset + offset;
   if (bfd_seek (abfd, pos, SEEK_SET) != 0
       || bfd_bwrite (location, count, abfd) != count)


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