summaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2013-02-18 23:50:26 +0000
committerAlan Modra <amodra@bigpond.net.au>2013-02-18 23:50:26 +0000
commitcb96b680825c6c5dd51fe8149c7adeecf8b82d8b (patch)
tree5a4bf2c053e93e1a61345b5ee8ca3474ff2cc6ef /bfd/elf.c
parent1404181eb634e539c00ffac210e66f93123f2168 (diff)
downloadbinutils-redhat-cb96b680825c6c5dd51fe8149c7adeecf8b82d8b.tar.gz
include/
* bfdlink.h (struct bfd_link_info): Delete emit_note_gnu_build_id. bfd/ * configure.in: Bump version to 2.23.52. * elf-bfd.h (struct elf_build_id_info): New. (struct elf_obj_tdata): Delete after_write_object_contents, after_write_object_contents_info and build_id_size. Make build_id a pointer to struct elf_build_id_info. * elf.c (_bfd_elf_write_object_contents): Style. Update after_write_ibject_contents invocation. (elfobj_grok_gnu_build_id): Update for new build_id struct. Don't allow zero size notes. * configure: Regenerate. gdb/ * elfread.c (struct build_id): Delete. Use struct elf_build_id throughout file instead. (build_id_bfd_get): Update to use new elf_tdata build_id field. Don't xmalloc return value. (build_id_verify): Similarly. Don't xfree. (build_id_to_debug_filename): Update. (find_separate_debug_file_by_buildid): Update, don't xfree. ld/ * emultempl/elf32.em (emit_note_gnu_build_id): New static var. Replace all info->emit_note_gnu_build_id refs. (id_note_section_size): Rename from gld${EMULATION_NAME}_id_note_section_size. (struct build_id_info): Delete. (write_build_id): Rename from gld${EMULATION_NAME}_write_build_id_section. Update elf_tdata usage. Style, formatting. (setup_build_id): New function. (gld${EMULATION_NAME}_after_open): Use setup_build_id.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 380f6eff2a..9020e55814 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5292,6 +5292,7 @@ _bfd_elf_write_object_contents (bfd *abfd)
Elf_Internal_Shdr **i_shdrp;
bfd_boolean failed;
unsigned int count, num_sec;
+ struct elf_obj_tdata *t;
if (! abfd->output_has_begun
&& ! _bfd_elf_compute_section_file_positions (abfd, NULL))
@@ -5323,21 +5324,22 @@ _bfd_elf_write_object_contents (bfd *abfd)
}
/* Write out the section header names. */
+ t = elf_tdata (abfd);
if (elf_shstrtab (abfd) != NULL
- && (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
+ && (bfd_seek (abfd, t->shstrtab_hdr.sh_offset, SEEK_SET) != 0
|| !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))))
return FALSE;
if (bed->elf_backend_final_write_processing)
- (*bed->elf_backend_final_write_processing) (abfd,
- elf_tdata (abfd)->linker);
+ (*bed->elf_backend_final_write_processing) (abfd, t->linker);
if (!bed->s->write_shdrs_and_ehdr (abfd))
return FALSE;
/* This is last since write_shdrs_and_ehdr can touch i_shdrp[0]. */
- if (elf_tdata (abfd)->after_write_object_contents)
- return (*elf_tdata (abfd)->after_write_object_contents) (abfd);
+ if (t->build_id != NULL
+ && t->build_id->u.o.zero == 0)
+ return (*t->build_id->u.o.after_write_object_contents) (abfd);
return TRUE;
}
@@ -8692,12 +8694,18 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
static bfd_boolean
elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
{
- elf_tdata (abfd)->build_id_size = note->descsz;
- elf_tdata (abfd)->build_id = (bfd_byte *) bfd_alloc (abfd, note->descsz);
- if (elf_tdata (abfd)->build_id == NULL)
+ struct elf_obj_tdata *t;
+
+ if (note->descsz == 0)
+ return FALSE;
+
+ t = elf_tdata (abfd);
+ t->build_id = bfd_alloc (abfd, sizeof (t->build_id->u.i) - 1 + note->descsz);
+ if (t->build_id == NULL)
return FALSE;
- memcpy (elf_tdata (abfd)->build_id, note->descdata, note->descsz);
+ t->build_id->u.i.size = note->descsz;
+ memcpy (t->build_id->u.i.data, note->descdata, note->descsz);
return TRUE;
}