aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-08-26 13:08:07 +0000
committerNick Clifton <nickc@redhat.com>2009-08-26 13:08:07 +0000
commite9e0a58e87c33963dda1800900c0e43b7c0213c0 (patch)
tree278ba8e8be0e8145d1c65c9df99d25e26ce54633
parent604ab327fde3345c5c9d76ce1983cfdc5fe45923 (diff)
downloadgdb-e9e0a58e87c33963dda1800900c0e43b7c0213c0.zip
gdb-e9e0a58e87c33963dda1800900c0e43b7c0213c0.tar.gz
gdb-e9e0a58e87c33963dda1800900c0e43b7c0213c0.tar.bz2
PR ld/10555
* emultempl/elf32.em (_after_open): Do not create a .note.gnu-build-id section if there are no input files.
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/emultempl/elf32.em53
2 files changed, 38 insertions, 21 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 49d2d6d..a24bbca 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-26 Nick Clifton <nickc@redhat.com>
+
+ PR ld/10555
+ * emultempl/elf32.em (_after_open): Do not create a
+ .note.gnu-build-id section if there are no input files.
+
2009-08-24 Nick Clifton <nickc@redhat.com>
* scripttempl/elfxtensa.sc (DISCARDED): Discard sections with
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index cd7f2d4..534a69c 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1049,37 +1049,48 @@ gld${EMULATION_NAME}_after_open (void)
abfd = link_info.input_bfds;
- size = gld${EMULATION_NAME}_id_note_section_size (abfd, &link_info);
- if (size == 0)
+ if (abfd == NULL)
{
- einfo ("%P: warning: unrecognized --build-id style ignored.\n");
+ /* PR 10555: If there are no input files do not
+ try to create a .note.gnu-build-id section. */
free (link_info.emit_note_gnu_build_id);
link_info.emit_note_gnu_build_id = NULL;
}
else
{
- s = bfd_make_section_with_flags (abfd, ".note.gnu.build-id",
- SEC_ALLOC | SEC_LOAD
- | SEC_IN_MEMORY | SEC_LINKER_CREATED
- | SEC_READONLY | SEC_DATA);
- if (s != NULL && bfd_set_section_alignment (abfd, s, 2))
+ size = gld${EMULATION_NAME}_id_note_section_size (abfd, &link_info);
+ if (size == 0)
{
- struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
- struct build_id_info *b = xmalloc (sizeof *b);
- b->style = link_info.emit_note_gnu_build_id;
- b->sec = s;
- elf_section_type (s) = SHT_NOTE;
- s->size = size;
- t->after_write_object_contents
- = &gld${EMULATION_NAME}_write_build_id_section;
- t->after_write_object_contents_info = b;
+ einfo ("%P: warning: unrecognized --build-id style ignored.\n");
+ free (link_info.emit_note_gnu_build_id);
+ link_info.emit_note_gnu_build_id = NULL;
}
else
{
- einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
- " --build-id ignored.\n");
- free (link_info.emit_note_gnu_build_id);
- link_info.emit_note_gnu_build_id = NULL;
+ s = bfd_make_section_with_flags (abfd, ".note.gnu.build-id",
+ SEC_ALLOC | SEC_LOAD
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_READONLY | SEC_DATA);
+ if (s != NULL && bfd_set_section_alignment (abfd, s, 2))
+ {
+ struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
+ struct build_id_info *b = xmalloc (sizeof *b);
+
+ b->style = link_info.emit_note_gnu_build_id;
+ b->sec = s;
+ elf_section_type (s) = SHT_NOTE;
+ s->size = size;
+ t->after_write_object_contents
+ = &gld${EMULATION_NAME}_write_build_id_section;
+ t->after_write_object_contents_info = b;
+ }
+ else
+ {
+ einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
+ " --build-id ignored.\n");
+ free (link_info.emit_note_gnu_build_id);
+ link_info.emit_note_gnu_build_id = NULL;
+ }
}
}
}