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/elf32-i386.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/elf32-i386.c')
-rw-r--r-- | bfd/elf32-i386.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 84299ce..7b33d77 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1027,12 +1027,6 @@ elf_i386_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) if (htab->plt_eh_frame == NULL || !bfd_set_section_alignment (dynobj, htab->plt_eh_frame, 2)) return FALSE; - - htab->plt_eh_frame->size = sizeof (elf_i386_eh_frame_plt); - htab->plt_eh_frame->contents - = bfd_alloc (dynobj, htab->plt_eh_frame->size); - memcpy (htab->plt_eh_frame->contents, elf_i386_eh_frame_plt, - sizeof (elf_i386_eh_frame_plt)); } return TRUE; @@ -2726,7 +2720,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) FALSE, FALSE, FALSE); /* Don't allocate .got.plt section if there are no GOT nor PLT - entries and there is no refeence to _GLOBAL_OFFSET_TABLE_. */ + entries and there is no reference to _GLOBAL_OFFSET_TABLE_. */ if ((got == NULL || !got->ref_regular_nonweak) && (htab->elf.sgotplt->size @@ -2742,6 +2736,14 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) 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)) + htab->plt_eh_frame->size = sizeof (elf_i386_eh_frame_plt); + /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ relocs = FALSE; @@ -2753,11 +2755,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) continue; if (s == htab->elf.splt - || s == htab->elf.sgot - || s == htab->elf.sgotplt - || s == htab->elf.iplt - || s == htab->elf.igotplt - || s == htab->sdynbss) + || s == htab->elf.sgot) { /* Strip this section if we don't need it; see the comment below. */ @@ -2768,6 +2766,14 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) if (htab->elf.hplt != NULL) strip_section = FALSE; } + else if (s == htab->elf.sgotplt + || s == htab->elf.iplt + || s == htab->elf.igotplt + || s == htab->plt_eh_frame + || s == htab->sdynbss) + { + /* Strip these too. */ + } else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rel")) { if (s->size != 0 @@ -2815,11 +2821,13 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) } 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) + { + memcpy (htab->plt_eh_frame->contents, elf_i386_eh_frame_plt, + sizeof (elf_i386_eh_frame_plt)); + bfd_put_32 (dynobj, htab->elf.splt->size, + htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET); + } if (htab->elf.dynamic_sections_created) { @@ -4840,7 +4848,8 @@ elf_i386_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 |