diff options
author | Roland McGrath <roland@gnu.org> | 2007-07-18 09:46:05 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2007-07-18 09:46:05 +0000 |
commit | b2ff8454d8a901f93484758ef2a0c2ebd4e64b72 (patch) | |
tree | 824006819271d5b9b9587bbbf8a16927582576b1 /ld/emultempl | |
parent | 9bd06a30b3c9708dec829e90067e5782dbb425c3 (diff) | |
download | gdb-b2ff8454d8a901f93484758ef2a0c2ebd4e64b72.zip gdb-b2ff8454d8a901f93484758ef2a0c2ebd4e64b72.tar.gz gdb-b2ff8454d8a901f93484758ef2a0c2ebd4e64b72.tar.bz2 |
2007-07-18 Roland McGrath <roland@redhat.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_write_build_id_section):
Use ASEC->contents for CONTENTS when missing, and allocate
ASEC->size if needed.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/elf32.em | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index ee34e3f..a3af5ca 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -945,12 +945,12 @@ gld${EMULATION_NAME}_write_build_id_section (bfd *abfd) if (i_shdr->contents == NULL) { - ASSERT (asec->output_offset == 0); - i_shdr->contents = xcalloc (i_shdr->sh_size, 1); - if (i_shdr->contents == NULL) - return FALSE; + if (asec->contents == NULL) + asec->contents = xmalloc (asec->size); + contents = asec->contents; } - contents = i_shdr->contents + asec->output_offset; + else + contents = i_shdr->contents + asec->output_offset; e_note = (void *) contents; size = offsetof (Elf_External_Note, name[sizeof "GNU"]); @@ -1019,9 +1019,10 @@ gld${EMULATION_NAME}_write_build_id_section (bfd *abfd) else abort (); /* Should have been validated earlier. */ - size = i_shdr->sh_size; - return (bfd_seek (abfd, i_shdr->sh_offset, SEEK_SET) == 0 - && bfd_bwrite (i_shdr->contents, size, abfd) == size); + size = asec->size; + return (bfd_seek (abfd, + i_shdr->sh_offset + asec->output_offset, SEEK_SET) == 0 + && bfd_bwrite (contents, size, abfd) == size); } |