From c0065db7328646edb30d44e0ed2d38e2d9cc3ea5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 9 Jul 2007 21:25:34 +0000 Subject: 2007-07-09 Roland McGrath * emultempl/elf32.em (gld${EMULATION_NAME}_add_option): Add --build-id. (gld${EMULATION_NAME}_handle_option): Handle --build-id. (gld${EMULATION_NAME}_list_options): List --build-id. (gld${EMULATION_NAME}_after_open): If --build-id was given, synthesize a ".note.gnu.build-id" section and cache it in elf_tdata. * ld.texinfo (Options): Describe --build-id. * NEWS: Mention --build-id. --- ld/emultempl/elf32.em | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'ld/emultempl/elf32.em') diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 3c7a82d..2a92f58 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -866,6 +866,45 @@ gld${EMULATION_NAME}_after_open (void) { struct bfd_link_needed_list *needed, *l; + if (link_info.emit_note_gnu_build_id) + { + bfd *abfd; + asection *s; + bfd_size_type size; + + abfd = link_info.input_bfds; + + size = _bfd_id_note_section_size (abfd, &link_info); + if (size == 0) + { + 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 + { + 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 (output_bfd); + t->emit_note_gnu_build_id = link_info.emit_note_gnu_build_id; + t->note_gnu_build_id_sec = s; + elf_section_type (s) = SHT_NOTE; + s->size = size; + } + 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; + } + } + } + if (link_info.eh_frame_hdr && ! link_info.traditional_format && ! link_info.relocatable) @@ -1760,6 +1799,7 @@ cat >>e${EMULATION_NAME}.c <>e${EMULATION_NAME}.c <>e${EMULATION_NAME}.c <