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]

Objcopy fix for relocation sections


I got a bug report that objcopy failed for shared libraries with "File
truncated" on arm-linux.  The problem was that ARM keeps relocations for
debug information, and objcopy never arranged for
elf.c:assign_file_position_for_relocs to be called.  This patch was the best
solution I could come up with - is it OK?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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]