diff options
author | Alan Modra <amodra@gmail.com> | 2012-05-25 01:12:20 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2012-05-25 01:12:20 +0000 |
commit | 9a2a56cc5a38cdf74d9a34557274ad055f8a8a62 (patch) | |
tree | fdc3a5feb7549b64f97919c64741a49e0905f92d /bfd/elf64-x86-64.c | |
parent | 3161ca4f50fe4f8bae8b6a3024b65961b02703c6 (diff) | |
download | gdb-9a2a56cc5a38cdf74d9a34557274ad055f8a8a62.zip gdb-9a2a56cc5a38cdf74d9a34557274ad055f8a8a62.tar.gz gdb-9a2a56cc5a38cdf74d9a34557274ad055f8a8a62.tar.bz2 |
PR ld/13909
* elf-eh-frame.c (_bfd_elf_eh_frame_present): New function.
(_bfd_elf_maybe_strip_eh_frame_hdr): Use it here.
* elf-bfd.h (_bfd_elf_eh_frame_present): Declare.
* elflink.c (bfd_elf_size_dynamic_sections): Let the backend
size dynamic sections before stripping eh_frame_hdr.
(bfd_elf_gc_sections): Handle multiple .eh_frame sections.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Drop glink_eh_frame
if no other .eh_frame sections exist.
* elf64-ppc.c (ppc64_elf_size_stubs): Likewise.
* elf32-i386.c (elf_i386_create_dynamic_sections): Don't size
or alloc plt_eh_frame here..
(elf_i386_size_dynamic_sections): ..do it here instead. Don't
specially keep sgotplt, iplt, tgotplt, sdynbss for symbols.
(elf_i386_finish_dynamic_sections): Check plt_eh_frame->contents
before writing plt offset.
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Don't size
or alloc plt_eh_frame here..
(elf_x86_64_size_dynamic_sections): ..do it here instead.
(elf_x86_64_finish_dynamic_sections): Check plt_eh_frame->contents
before writing plt offset.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r-- | bfd/elf64-x86-64.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 1f490d4..abd8d60 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -982,8 +982,6 @@ elf_x86_64_create_dynamic_sections (bfd *dynobj, && htab->plt_eh_frame == NULL && htab->elf.splt != NULL) { - const struct elf_x86_64_backend_data *const abed - = get_elf_x86_64_backend_data (dynobj); flagword flags = get_elf_backend_data (dynobj)->dynamic_sec_flags; htab->plt_eh_frame = bfd_make_section_anyway_with_flags (dynobj, ".eh_frame", @@ -993,12 +991,6 @@ elf_x86_64_create_dynamic_sections (bfd *dynobj, if (htab->plt_eh_frame == NULL || !bfd_set_section_alignment (dynobj, htab->plt_eh_frame, 3)) return FALSE; - - htab->plt_eh_frame->size = abed->eh_frame_plt_size; - htab->plt_eh_frame->contents - = bfd_alloc (dynobj, htab->plt_eh_frame->size); - memcpy (htab->plt_eh_frame->contents, - abed->eh_frame_plt, abed->eh_frame_plt_size); } return TRUE; } @@ -2797,6 +2789,17 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, htab->elf.sgotplt->size = 0; } + if (htab->plt_eh_frame != NULL + && htab->elf.splt != NULL + && htab->elf.splt->size != 0 + && !bfd_is_abs_section (htab->elf.splt->output_section) + && _bfd_elf_eh_frame_present (info)) + { + const struct elf_x86_64_backend_data *arch_data + = (const struct elf_x86_64_backend_data *) bed->arch_data; + htab->plt_eh_frame->size = arch_data->eh_frame_plt_size; + } + /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ relocs = FALSE; @@ -2810,6 +2813,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, || s == htab->elf.sgotplt || s == htab->elf.iplt || s == htab->elf.igotplt + || s == htab->plt_eh_frame || s == htab->sdynbss) { /* Strip this section if we don't need it; see the @@ -2861,11 +2865,16 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, } if (htab->plt_eh_frame != NULL - && htab->elf.splt != NULL - && htab->elf.splt->size != 0 - && (htab->elf.splt->flags & SEC_EXCLUDE) == 0) - bfd_put_32 (dynobj, htab->elf.splt->size, - htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET); + && htab->plt_eh_frame->contents != NULL) + { + const struct elf_x86_64_backend_data *arch_data + = (const struct elf_x86_64_backend_data *) bed->arch_data; + + memcpy (htab->plt_eh_frame->contents, + arch_data->eh_frame_plt, htab->plt_eh_frame->size); + bfd_put_32 (dynobj, htab->elf.splt->size, + htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET); + } if (htab->elf.dynamic_sections_created) { @@ -4725,7 +4734,8 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd, } /* Adjust .eh_frame for .plt section. */ - if (htab->plt_eh_frame != NULL) + if (htab->plt_eh_frame != NULL + && htab->plt_eh_frame->contents != NULL) { if (htab->elf.splt != NULL && htab->elf.splt->size != 0 |