summaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2013-02-21 04:35:14 +0000
committerAlan Modra <amodra@bigpond.net.au>2013-02-21 04:35:14 +0000
commit9d055f19e35f94f05f2ccdeee57b8f36b0a5cbb9 (patch)
tree223e8310143b6793e25a5f1c9dca655885d8e8e1 /bfd/elf.c
parent20812afb15f97fa57b2c909d211d73be08e692ce (diff)
downloadgdb-9d055f19e35f94f05f2ccdeee57b8f36b0a5cbb9.tar.gz
bfd/
* elf-bfd.h (struct elf_build_id): Extracted from.. (struct elf_build_id_info): ..here. Delete. (struct output_elf_obj_tdata): New, extracted from.. (struct elf_obj_tdata): ..here. Reorganize for better packing. Add "o" field. (elf_program_header_size): Reference tdata->o. (elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker, elf_stack_flags, elf_shstrtab, elf_strtab_sec, elf_shstrtab_sec, elf_section_syms, elf_num_section_syms, elf_flags_init): Likewise. * elf.c (bfd_elf_allocate_object): Allocate output_elf_obj_tdata when opening bfd in any mode that might write. (_bfd_elf_write_object_contents): Use build_id field in output_elf_obj_tdata. (_bfd_elf_close_and_cleanup): Tweak elf_shstrtab test. (elfobj_grok_gnu_build_id): Adjust for elf_tdata changes. gdb/ * elfread.c (build_id_bfd_get): Adjust for elf_tdata changes. ld/ * emultempl/elf32.em (write_build_id, setup_build_id): Adjust for elf_tdata changes.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 09cd93a6fa0..e0487c2c915 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -246,7 +246,14 @@ bfd_elf_allocate_object (bfd *abfd,
return FALSE;
elf_object_id (abfd) = object_id;
- elf_program_header_size (abfd) = (bfd_size_type) -1;
+ if (abfd->direction != read_direction)
+ {
+ struct output_elf_obj_tdata *o = bfd_zalloc (abfd, sizeof *o);
+ if (o == NULL)
+ return FALSE;
+ elf_tdata (abfd)->o = o;
+ elf_program_header_size (abfd) = (bfd_size_type) -1;
+ }
return TRUE;
}
@@ -5333,9 +5340,8 @@ _bfd_elf_write_object_contents (bfd *abfd)
return FALSE;
/* This is last since write_shdrs_and_ehdr can touch i_shdrp[0]. */
- if (t->build_id != NULL
- && t->build_id->u.o.zero == 0)
- return (*t->build_id->u.o.after_write_object_contents) (abfd);
+ if (t->o->build_id.after_write_object_contents != NULL)
+ return (*t->o->build_id.after_write_object_contents) (abfd);
return TRUE;
}
@@ -7874,7 +7880,7 @@ _bfd_elf_close_and_cleanup (bfd *abfd)
struct elf_obj_tdata *tdata = elf_tdata (abfd);
if (bfd_get_format (abfd) == bfd_object && tdata != NULL)
{
- if (elf_shstrtab (abfd) != NULL)
+ if (elf_tdata (abfd)->o != NULL && elf_shstrtab (abfd) != NULL)
_bfd_elf_strtab_free (elf_shstrtab (abfd));
_bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info);
}
@@ -8697,12 +8703,12 @@ elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
return FALSE;
t = elf_tdata (abfd);
- t->build_id = bfd_alloc (abfd, sizeof (t->build_id->u.i) - 1 + note->descsz);
+ t->build_id = bfd_alloc (abfd, sizeof (*t->build_id) - 1 + note->descsz);
if (t->build_id == NULL)
return FALSE;
- t->build_id->u.i.size = note->descsz;
- memcpy (t->build_id->u.i.data, note->descdata, note->descsz);
+ t->build_id->size = note->descsz;
+ memcpy (t->build_id->data, note->descdata, note->descsz);
return TRUE;
}