This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH bfin] Discard zero size sections for Blackfin ELF FD-PIC
- From: Jie Zhang <jie dot zhang at analog dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 4 Sep 2009 11:37:11 +0800
- Subject: [PATCH bfin] Discard zero size sections for Blackfin ELF FD-PIC
.rela.bss and .rel.plt are created in
elf32_bfinfdpic_create_dynamic_sections (). If they are not used later,
they should be discarded in elf32_bfinfdpic_size_dynamic_sections ().
This patch fixes
FAIL: simple objcopy of executable
for bfin-linux-uclibc target.
Committed.
Jie
* elf32-bfin.c (elf32_bfinfdpic_create_dynamic_sections): Always
create .rela.bss.
(elf32_bfinfdpic_size_dynamic_sections): Set SEC_EXCLUDE flag
for empty .rela.bss and .rel.plt sections.
Index: elf32-bfin.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-bfin.c,v
retrieving revision 1.41
diff -u -p -r1.41 elf32-bfin.c
--- elf32-bfin.c 2 Sep 2009 07:18:36 -0000 1.41
+++ elf32-bfin.c 4 Sep 2009 03:31:35 -0000
@@ -3559,8 +3559,7 @@ elf32_bfinfdpic_create_dynamic_sections
if (! info->shared)
{
s = bfd_make_section_with_flags (abfd,
- (bed->default_use_rela_p
- ? ".rela.bss" : ".rel.bss"),
+ ".rela.bss",
flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
@@ -4299,6 +4298,15 @@ elf32_bfinfdpic_size_dynamic_sections (b
return FALSE;
}
+
+ s = bfd_get_section_by_name (dynobj, ".rela.bss");
+ if (s && s->size == 0)
+ s->flags |= SEC_EXCLUDE;
+
+ s = bfd_get_section_by_name (dynobj, ".rel.plt");
+ if (s && s->size == 0)
+ s->flags |= SEC_EXCLUDE;
+
return TRUE;
}