bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 13 Mar 2009 13:39:57 +0000 (13:39 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 13 Mar 2009 13:39:57 +0000 (13:39 +0000)
2009-03-13  H.J. Lu  <hongjiu.lu@intel.com>

PR binutils/9945
* elf.c (assign_section_numbers): Generate symbol table if there
is any relocation in output.
(_bfd_elf_compute_section_file_positions): Likewise.

binutils/

2009-03-13  H.J. Lu  <hongjiu.lu@intel.com>

PR binutils/9945
* objcopy.c (copy_object): Clear HAS_RELOC when stripping all.

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

index 7cbe0a22b17b5f09898420accf780b3bf412d6fd..5bd669d4d9fc30a06f7d7e3271e9716989d62d76 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/9945
+       * elf.c (assign_section_numbers): Generate symbol table if there
+       is any relocation in output.
+       (_bfd_elf_compute_section_file_positions): Likewise.
+
 2009-03-13  Nick Clifton  <nickc@redhat.com>
 
        PR 9934
index 97ac5cbc42de63430dc4b776c0c8c72481258960..8ca5ef9a62e07660510e51050e5881709024da8f 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2774,6 +2774,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
   unsigned int section_number, secn;
   Elf_Internal_Shdr **i_shdrp;
   struct bfd_elf_section_data *d;
+  bfd_boolean need_symtab;
 
   section_number = 1;
 
@@ -2829,7 +2830,11 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
   _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name);
   elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
 
-  if (bfd_get_symcount (abfd) > 0)
+  need_symtab = (bfd_get_symcount (abfd) > 0
+               || (link_info == NULL
+                   && ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC))
+                       == HAS_RELOC)));
+  if (need_symtab)
     {
       t->symtab_section = section_number++;
       _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name);
@@ -2868,7 +2873,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
   elf_elfsections (abfd) = i_shdrp;
 
   i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
-  if (bfd_get_symcount (abfd) > 0)
+  if (need_symtab)
     {
       i_shdrp[t->symtab_section] = &t->symtab_hdr;
       if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))
@@ -3261,6 +3266,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
   bfd_boolean failed;
   struct bfd_strtab_hash *strtab = NULL;
   Elf_Internal_Shdr *shstrtab_hdr;
+  bfd_boolean need_symtab;
 
   if (abfd->output_has_begun)
     return TRUE;
@@ -3285,7 +3291,11 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
     return FALSE;
 
   /* The backend linker builds symbol table information itself.  */
-  if (link_info == NULL && bfd_get_symcount (abfd) > 0)
+  need_symtab = (link_info == NULL
+                && (bfd_get_symcount (abfd) > 0
+                    || ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC))
+                        == HAS_RELOC)));
+  if (need_symtab)
     {
       /* Non-zero if doing a relocatable link.  */
       int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));
@@ -3316,7 +3326,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
   if (!assign_file_positions_except_relocs (abfd, link_info))
     return FALSE;
 
-  if (link_info == NULL && bfd_get_symcount (abfd) > 0)
+  if (need_symtab)
     {
       file_ptr off;
       Elf_Internal_Shdr *hdr;
index b5a7f6c22e0c80f674b64e8c24eef513936cf3c7..87badcd2da7e2fff9a9a8e5f9ecb5f81ef9bd7ec 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/9945
+       * objcopy.c (copy_object): Clear HAS_RELOC when stripping all.
+
 2009-03-11  Chris Demetriou  <cgd@google.com>
 
        * ar.c (deterministic): New global variable.
index 07d4f3f3a4dcb214f66348d8eb493ae3d1c19e48..9dcf9b5150a12ca510db9b9acffb4f3128dc0b5f 100644 (file)
@@ -1396,6 +1396,9 @@ copy_object (bfd *ibfd, bfd *obfd)
       flags &= ~bfd_flags_to_clear;
       flags &= bfd_applicable_file_flags (obfd);
 
+      if (strip_symbols == STRIP_ALL)
+       flags &= ~HAS_RELOC;
+
       if (!bfd_set_start_address (obfd, start)
          || !bfd_set_file_flags (obfd, flags))
        {
This page took 0.048062 seconds and 4 git commands to generate.