]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/
authorAlan Modra <amodra@gmail.com>
Wed, 30 May 2007 14:29:27 +0000 (14:29 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 30 May 2007 14:29:27 +0000 (14:29 +0000)
* elf.c (elf_fake_sections): Adjust test for SHT_NOBITS sections
created by objcopy --only-keep-debug.
(_bfd_elf_init_private_section_data): Only change elf_section_type
if it is SHT_NULL.
binutils/
* objcopy.c (copy_object): Revert 2007-05-11 change.  Don't
avoid calling bfd_copy_private_bfd_data for ELF STRIP_NONDEBUG.
(setup_section): Don't modify flags, and don't avoid calling
bfd_copy_private_section_data for ELF STRIP_NONDEBUG.
* readelf.c (process_program_headers): Ignore .dynamic of type
SHT_NOBITS.

bfd/ChangeLog
bfd/elf.c
binutils/ChangeLog
binutils/objcopy.c
binutils/readelf.c

index 01d0436fab90b13e43a2d990a9b5d5e23d19ac27..a75421305b207b6280e64914afb34d26e3cbf096 100644 (file)
@@ -1,5 +1,10 @@
 2007-05-30  Alan Modra  <amodra@bigpond.net.au>
 
+       * elf.c (elf_fake_sections): Adjust test for SHT_NOBITS sections
+       created by objcopy --only-keep-debug.
+       (_bfd_elf_init_private_section_data): Only change elf_section_type
+       if it is SHT_NULL.
+
        * elf.c (assign_file_positions_for_load_sections): Correct sh_type
        to SHT_NOBITS earlier.  Base actions in rest of function on sh_type
        and sh_flags instead of bfd section flags.  Delete voff and code
index 25266eaae8ba402c7a57482d154599c28d1f9274..532e6b574926dbef9427c6f06fce0823dfbfad84 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2907,11 +2907,10 @@ elf_fake_sections (bfd *abfd, asection *asect, void *failedptrarg)
       && !(*bed->elf_backend_fake_sections) (abfd, this_hdr, asect))
     *failedptr = TRUE;
 
-  if (sh_type == SHT_NOBITS
-      && elf_elfheader (abfd)->e_phnum == 0)
+  if (sh_type == SHT_NOBITS && asect->size != 0)
     {
       /* Don't change the header type from NOBITS if we are being
-        called for strip/objcopy --only-keep-debug.  */
+        called for objcopy --only-keep-debug.  */
       this_hdr->sh_type = sh_type;
     }
 
@@ -6039,13 +6038,9 @@ _bfd_elf_init_private_section_data (bfd *ibfd,
      output BFD section flags have been set to something different.
      elf_fake_sections will set ELF section type based on BFD
      section flags.  */
-  if (osec->flags == isec->flags || !osec->flags)
-    {
-      BFD_ASSERT (osec->flags == isec->flags 
-                 || (!osec->flags
-                     && elf_section_type (osec) == SHT_NULL));
-      elf_section_type (osec) = elf_section_type (isec);
-    }
+  if (elf_section_type (osec) == SHT_NULL
+      && (osec->flags == isec->flags || !osec->flags))
+    elf_section_type (osec) = elf_section_type (isec);
 
   /* FIXME: Is this correct for all OS/PROC specific flags?  */
   elf_section_flags (osec) |= (elf_section_flags (isec)
index e2ffe4526ac1984bcef14c00114cf7105926159e..e56701abad692bc41379767f2ceea925ce7b38ca 100644 (file)
@@ -1,3 +1,12 @@
+2007-05-30  Alan Modra  <amodra@bigpond.net.au>
+
+       * objcopy.c (copy_object): Revert 2007-05-11 change.  Don't
+       avoid calling bfd_copy_private_bfd_data for ELF STRIP_NONDEBUG.
+       (setup_section): Don't modify flags, and don't avoid calling
+       bfd_copy_private_section_data for ELF STRIP_NONDEBUG.
+       * readelf.c (process_program_headers): Ignore .dynamic of type
+       SHT_NOBITS.
+
 2007-05-29  Alan Modra  <amodra@bigpond.net.au>
 
        * embedspu.sh: Emit SPU ELF image to .data.rel.ro.speelf if
index 4d69033756137e4ac80d3f15672f56e6e8a52b5d..3cfb831af40cef704915a48394af7d5afc07cdb4 100644 (file)
@@ -1423,12 +1423,7 @@ 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);
 
-  /* 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);
+  setup_bfd_headers (ibfd, obfd);
 
   if (add_sections != NULL)
     {
@@ -1771,12 +1766,7 @@ copy_object (bfd *ibfd, bfd *obfd)
      from the input BFD to the output BFD.  This is done last to
      permit the routine to look at the filtered symbol table, which is
      important for the ECOFF code at least.  */
-  if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour
-      && strip_symbols == STRIP_NONDEBUG)
-    /* Do not copy the private data when creating an ELF format
-       debug info file.  We do not want the program headers.  */
-    ;
-  else if (! bfd_copy_private_bfd_data (ibfd, obfd))
+  if (! bfd_copy_private_bfd_data (ibfd, obfd))
     {
       non_fatal (_("%s: error copying private BFD data: %s"),
                 bfd_get_filename (obfd),
@@ -2206,7 +2196,9 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
 
   if (p != NULL && p->set_flags)
     flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
-  else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0)
+  else if (strip_symbols == STRIP_NONDEBUG
+          && obfd->xvec->flavour != bfd_target_elf_flavour
+          && (flags & SEC_ALLOC) != 0)
     flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
 
   osection = bfd_make_section_anyway_with_flags (obfd, name, flags);
@@ -2289,12 +2281,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
 
   /* Allow the BFD backend to copy any private data it understands
      from the input section to the output section.  */
-  if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour
-      && strip_symbols == STRIP_NONDEBUG)
-    /* Do not copy the private data when creating an ELF format
-       debug info file.  We do not want the program headers.  */
-    ;
-  else if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
+  if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
     {
       err = _("private data");
       goto loser;
index 14dbb52f6730206265ea9e8ceca43c5a7e336200..165aa61e0a91b8d8a2e1c52b0788e5267ed9a68f 100644 (file)
@@ -3516,6 +3516,9 @@ process_program_headers (FILE *file)
                  break;
                }
 
+             if (sec->sh_type == SHT_NOBITS)
+               break;
+
              dynamic_addr = sec->sh_offset;
              dynamic_size = sec->sh_size;