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]

objcopy --only-keep-debug and ELF program headers


This removes program headers entirely from ELF debug info files.
I can't see that they're needed, and existing comments in objcopy.c
tend to reinforce this.  Furthermore, a quick hello world test shows
gdb is happy.  However, I'll wait for Nick to give the OK on this one
since I haven't played much with separate debug info.

	PR 4479
	* objcopy.c (copy_object): Don't copy ELF program headers for
	--only-keep-debug.

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.110
diff -u -p -r1.110 objcopy.c
--- binutils/objcopy.c	26 Apr 2007 14:46:59 -0000	1.110
+++ binutils/objcopy.c	10 May 2007 05:25:13 -0000
@@ -1423,7 +1423,12 @@ copy_object (bfd *ibfd, bfd *obfd)
      any output is done.  Thus, we traverse all sections multiple times.  */
   bfd_map_over_sections (ibfd, setup_section, obfd);
 
-  setup_bfd_headers (ibfd, obfd);
+  /* Don't copy headers when creating an ELF format debug info file.  */
+  if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour
+      && strip_symbols == STRIP_NONDEBUG)
+    ;
+  else
+    setup_bfd_headers (ibfd, obfd);
 
   if (add_sections != NULL)
     {

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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