[914669c] | 1 | http://sourceware.org/bugzilla/show_bug.cgi?id=9945 |
---|
| 2 | |
---|
| 3 | 2009-03-13 H.J. Lu <hongjiu.lu@intel.com> |
---|
| 4 | |
---|
| 5 | PR binutils/9945 |
---|
| 6 | * elf.c (assign_section_numbers): Generate symbol table if there |
---|
| 7 | is any relocation in output. |
---|
| 8 | (_bfd_elf_compute_section_file_positions): Likewise. |
---|
| 9 | |
---|
| 10 | 2009-03-13 H.J. Lu <hongjiu.lu@intel.com> |
---|
| 11 | |
---|
| 12 | PR binutils/9945 |
---|
| 13 | * objcopy.c (copy_object): Clear HAS_RELOC when stripping all. |
---|
| 14 | |
---|
| 15 | =================================================================== |
---|
| 16 | RCS file: /cvs/src/src/bfd/elf.c,v |
---|
| 17 | retrieving revision 1.477 |
---|
| 18 | retrieving revision 1.478 |
---|
| 19 | diff -u -r1.477 -r1.478 |
---|
| 20 | --- src/bfd/elf.c 2009/02/25 14:39:35 1.477 |
---|
| 21 | +++ src/bfd/elf.c 2009/03/13 13:39:56 1.478 |
---|
| 22 | @@ -2774,6 +2774,7 @@ |
---|
| 23 | unsigned int section_number, secn; |
---|
| 24 | Elf_Internal_Shdr **i_shdrp; |
---|
| 25 | struct bfd_elf_section_data *d; |
---|
| 26 | + bfd_boolean need_symtab; |
---|
| 27 | |
---|
| 28 | section_number = 1; |
---|
| 29 | |
---|
| 30 | @@ -2829,7 +2830,11 @@ |
---|
| 31 | _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name); |
---|
| 32 | elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section; |
---|
| 33 | |
---|
| 34 | - if (bfd_get_symcount (abfd) > 0) |
---|
| 35 | + need_symtab = (bfd_get_symcount (abfd) > 0 |
---|
| 36 | + || (link_info == NULL |
---|
| 37 | + && ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC)) |
---|
| 38 | + == HAS_RELOC))); |
---|
| 39 | + if (need_symtab) |
---|
| 40 | { |
---|
| 41 | t->symtab_section = section_number++; |
---|
| 42 | _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name); |
---|
| 43 | @@ -2868,7 +2873,7 @@ |
---|
| 44 | elf_elfsections (abfd) = i_shdrp; |
---|
| 45 | |
---|
| 46 | i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr; |
---|
| 47 | - if (bfd_get_symcount (abfd) > 0) |
---|
| 48 | + if (need_symtab) |
---|
| 49 | { |
---|
| 50 | i_shdrp[t->symtab_section] = &t->symtab_hdr; |
---|
| 51 | if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF)) |
---|
| 52 | @@ -3261,6 +3266,7 @@ |
---|
| 53 | bfd_boolean failed; |
---|
| 54 | struct bfd_strtab_hash *strtab = NULL; |
---|
| 55 | Elf_Internal_Shdr *shstrtab_hdr; |
---|
| 56 | + bfd_boolean need_symtab; |
---|
| 57 | |
---|
| 58 | if (abfd->output_has_begun) |
---|
| 59 | return TRUE; |
---|
| 60 | @@ -3285,7 +3291,11 @@ |
---|
| 61 | return FALSE; |
---|
| 62 | |
---|
| 63 | /* The backend linker builds symbol table information itself. */ |
---|
| 64 | - if (link_info == NULL && bfd_get_symcount (abfd) > 0) |
---|
| 65 | + need_symtab = (link_info == NULL |
---|
| 66 | + && (bfd_get_symcount (abfd) > 0 |
---|
| 67 | + || ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC)) |
---|
| 68 | + == HAS_RELOC))); |
---|
| 69 | + if (need_symtab) |
---|
| 70 | { |
---|
| 71 | /* Non-zero if doing a relocatable link. */ |
---|
| 72 | int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC)); |
---|
| 73 | @@ -3316,7 +3326,7 @@ |
---|
| 74 | if (!assign_file_positions_except_relocs (abfd, link_info)) |
---|
| 75 | return FALSE; |
---|
| 76 | |
---|
| 77 | - if (link_info == NULL && bfd_get_symcount (abfd) > 0) |
---|
| 78 | + if (need_symtab) |
---|
| 79 | { |
---|
| 80 | file_ptr off; |
---|
| 81 | Elf_Internal_Shdr *hdr; |
---|
| 82 | =================================================================== |
---|
| 83 | RCS file: /cvs/src/src/binutils/objcopy.c,v |
---|
| 84 | retrieving revision 1.126 |
---|
| 85 | retrieving revision 1.127 |
---|
| 86 | diff -u -r1.126 -r1.127 |
---|
| 87 | --- src/binutils/objcopy.c 2009/03/10 00:48:09 1.126 |
---|
| 88 | +++ src/binutils/objcopy.c 2009/03/13 13:39:57 1.127 |
---|
| 89 | @@ -1396,6 +1396,9 @@ |
---|
| 90 | flags &= ~bfd_flags_to_clear; |
---|
| 91 | flags &= bfd_applicable_file_flags (obfd); |
---|
| 92 | |
---|
| 93 | + if (strip_symbols == STRIP_ALL) |
---|
| 94 | + flags &= ~HAS_RELOC; |
---|
| 95 | + |
---|
| 96 | if (!bfd_set_start_address (obfd, start) |
---|
| 97 | || !bfd_set_file_flags (obfd, flags)) |
---|
| 98 | { |
---|
| 99 | |
---|