summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-02-02 03:30:21 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-02-02 03:30:48 -0800
commit14f2c699ddca1e2f706342dffc59a6c7e23e844c (patch)
tree1c139746a08e92bb640f08145d0ca4f28d696571 /bfd
parenta143b0045ca8a7024a8515b5dda3ceab5f832e83 (diff)
Clear HAS_RELOC if there are no relocations
The HAS_RELOC bit should be cleared when relocations are removed from relocatable files. bfd/ PR binutils/19547 * elf.c (assign_section_numbers): Clear HAS_RELOC if there are no relocations in relocatable files. binutils/ PR binutils/19547 * testsuite/binutils-all/objcopy.exp (objcopy_test_without_global_symbol): New proc. Run objcopy_test_without_global_symbol. * testsuite/binutils-all/pr19547.c: New file.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c9
2 files changed, 15 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 06596f9d5e..898af5684a 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-02-02 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/19547
+ * elf.c (assign_section_numbers): Clear HAS_RELOC if there are
+ no relocations in relocatable files.
+
2016-02-01 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19553
diff --git a/bfd/elf.c b/bfd/elf.c
index 74c2f2d33a..30112ae900 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3355,6 +3355,8 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
/* SHT_GROUP sections are in relocatable files only. */
if (link_info == NULL || bfd_link_relocatable (link_info))
{
+ bfd_size_type reloc_count = 0;
+
/* Put SHT_GROUP sections first. */
for (sec = abfd->sections; sec != NULL; sec = sec->next)
{
@@ -3371,7 +3373,14 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
else
d->this_idx = section_number++;
}
+
+ /* Count relocations. */
+ reloc_count += sec->reloc_count;
}
+
+ /* Clear HAS_RELOC if there are no relocations. */
+ if (reloc_count == 0)
+ abfd->flags &= ~HAS_RELOC;
}
for (sec = abfd->sections; sec; sec = sec->next)