diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2009-06-16 13:41:10 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2009-06-16 13:41:10 +0000 |
commit | 6de2ae4a2a0020a827f05f30dedf8dcec7e77ee0 (patch) | |
tree | 1b803d87f6a3acfc6bebad13e80d25fbbd3aec2e /bfd/elflink.c | |
parent | 671f4ed1aa129d71951e461890cbfdb1f5209d99 (diff) | |
download | gdb-6de2ae4a2a0020a827f05f30dedf8dcec7e77ee0.zip gdb-6de2ae4a2a0020a827f05f30dedf8dcec7e77ee0.tar.gz gdb-6de2ae4a2a0020a827f05f30dedf8dcec7e77ee0.tar.bz2 |
2009-06-16 H.J. Lu <hongjiu.lu@intel.com>
* configure.in (elf): Add elf-ifunc.lo.
* configure: Regenerated.
* Makefile.in: Likewise.
* elf-bfd.h (elf_link_hash_table): Add sgot, sgotplt,
srelgot, splt, srelplt, igotplt, iplt, irelplt and irelifunc.
* elf32-i386.c (elf_i386_link_hash_table): Remove sgot,
sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
irelifunc.
(elf_i386_link_hash_table_create): Likewise.
(elf_i386_create_dynamic_sections): Likewise.
(elf_i386_check_relocs): Likewise.
(elf_i386_allocate_dynrelocs): Likewise.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(elf_i386_finish_dynamic_sections): Likewise.
(elf_i386_create_got_section): Removed.
* elf64-x86-64.c (elf64_x86_64_link_hash_table): Remove sgot,
sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
irelifunc.
(elf64_x86_64_compute_jump_table_size): Updated.
(elf64_x86_64_link_hash_table_create): Likewise.
(elf64_x86_64_create_dynamic_sections): Likewise.
(elf64_x86_64_check_relocs): Likewise.
(elf64_x86_64_allocate_dynrelocs): Likewise.
(elf64_x86_64_size_dynamic_sections): Likewise.
(elf64_x86_64_relocate_section): Likewise.
(elf64_x86_64_finish_dynamic_symbol): Likewise.
(elf64_x86_64_finish_dynamic_sections): Likewise.
(elf64_x86_64_create_got_section): Removed.
* elflink.c (_bfd_elf_create_got_section): Use log_file_align
for pointer alignment. Set up section pointers.
(_bfd_elf_create_dynamic_sections): Likewise.
(_bfd_elf_create_ifunc_sections): Moved to ...
* elf-ifunc.c: Here. New.
* Makefile.am (BFD32_BACKENDS): Add elf-ifunc.lo.
(BFD32_BACKENDS_CFILES): Add elf-ifunc.c.
Run "make dep-am".
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 132 |
1 files changed, 21 insertions, 111 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index e3a1670..f1bceae 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -101,41 +101,39 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) asection *s; struct elf_link_hash_entry *h; const struct elf_backend_data *bed = get_elf_backend_data (abfd); - int ptralign; + struct elf_link_hash_table *htab = elf_hash_table (info); /* This function may be called more than once. */ s = bfd_get_section_by_name (abfd, ".got"); if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0) return TRUE; - switch (bed->s->arch_size) - { - case 32: - ptralign = 2; - break; - - case 64: - ptralign = 3; - break; - - default: - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - flags = bed->dynamic_sec_flags; s = bfd_make_section_with_flags (abfd, ".got", flags); if (s == NULL - || !bfd_set_section_alignment (abfd, s, ptralign)) + || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) return FALSE; + htab->sgot = s; + + s = bfd_make_section_with_flags (abfd, + (bed->rela_plts_and_copies_p + ? ".rela.got" : ".rel.got"), + (bed->dynamic_sec_flags + | SEC_READONLY)); + if (s == NULL + || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) + return FALSE; + htab->srelgot = s; if (bed->want_got_plt) { s = bfd_make_section_with_flags (abfd, ".got.plt", flags); if (s == NULL - || !bfd_set_section_alignment (abfd, s, ptralign)) + || !bfd_set_section_alignment (abfd, s, + bed->s->log_file_align)) return FALSE; + htab->sgotplt = s; } if (bed->want_got_sym) @@ -144,7 +142,8 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) (or .got.plt) section. We don't do this in the linker script because we don't want to define the symbol if we are not creating a global offset table. */ - h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_"); + h = _bfd_elf_define_linkage_sym (abfd, info, s, + "_GLOBAL_OFFSET_TABLE_"); elf_hash_table (info)->hgot = h; if (h == NULL) return FALSE; @@ -303,6 +302,7 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) struct elf_link_hash_entry *h; asection *s; const struct elf_backend_data *bed = get_elf_backend_data (abfd); + struct elf_link_hash_table *htab = elf_hash_table (info); /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and .rel[a].bss sections. */ @@ -323,6 +323,7 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (s == NULL || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) return FALSE; + htab->splt = s; /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section. */ @@ -342,6 +343,7 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (s == NULL || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) return FALSE; + htab->srelplt = s; if (! _bfd_elf_create_got_section (abfd, info)) return FALSE; @@ -12491,95 +12493,3 @@ _bfd_elf_make_dynamic_reloc_section (asection * sec, return reloc_sec; } - -/* Create sections needed by STT_GNU_IFUNC symbol. */ - -bfd_boolean -_bfd_elf_create_ifunc_sections (bfd *abfd, struct bfd_link_info *info) -{ - flagword flags, pltflags; - int ptralign; - asection *s; - const struct elf_backend_data *bed = get_elf_backend_data (abfd); - - flags = bed->dynamic_sec_flags; - pltflags = flags; - if (bed->plt_not_loaded) - /* We do not clear SEC_ALLOC here because we still want the OS to - allocate space for the section; it's just that there's nothing - to read in from the object file. */ - pltflags &= ~ (SEC_CODE | SEC_LOAD | SEC_HAS_CONTENTS); - else - pltflags |= SEC_ALLOC | SEC_CODE | SEC_LOAD; - if (bed->plt_readonly) - pltflags |= SEC_READONLY; - - if (info->shared) - { - /* We need to create .rel[a].ifunc for shared objects. */ - const char *rel_sec = (bed->rela_plts_and_copies_p - ? ".rela.ifunc" : ".rel.ifunc"); - - /* This function should be called only once. */ - s = bfd_get_section_by_name (abfd, rel_sec); - if (s != NULL) - abort (); - - s = bfd_make_section_with_flags (abfd, rel_sec, - flags | SEC_READONLY); - if (s == NULL - || ! bfd_set_section_alignment (abfd, s, - bed->s->log_file_align)) - return FALSE; - } - else - { - /* This function should be called only once. */ - s = bfd_get_section_by_name (abfd, ".iplt"); - if (s != NULL) - abort (); - - /* We need to create .iplt, .rel[a].iplt, .igot and .igot.plt - for static executables. */ - s = bfd_make_section_with_flags (abfd, ".iplt", pltflags); - if (s == NULL - || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) - return FALSE; - - s = bfd_make_section_with_flags (abfd, - (bed->rela_plts_and_copies_p - ? ".rela.iplt" : ".rel.iplt"), - flags | SEC_READONLY); - if (s == NULL - || ! bfd_set_section_alignment (abfd, s, - bed->s->log_file_align)) - return FALSE; - - switch (bed->s->arch_size) - { - case 32: - ptralign = 2; - break; - - case 64: - ptralign = 3; - break; - - default: - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - - /* We don't need the .igot section if we have the .igot.plt - section. */ - if (bed->want_got_plt) - s = bfd_make_section_with_flags (abfd, ".igot.plt", flags); - else - s = bfd_make_section_with_flags (abfd, ".igot", flags); - if (s == NULL - || !bfd_set_section_alignment (abfd, s, ptralign)) - return FALSE; - } - - return TRUE; -} |