diff options
author | Ian Lance Taylor <ian@airs.com> | 1997-01-03 22:09:40 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1997-01-03 22:09:40 +0000 |
commit | ff12f303355b20de1260bc1d007f973bd02615dc (patch) | |
tree | 405f3b582a787fe20c609cda43409e3105cb6b38 /bfd/elflink.c | |
parent | 98141a3cc1a9e2a5c11abc9d9f6c34e30f7e2b64 (diff) | |
download | gdb-ff12f303355b20de1260bc1d007f973bd02615dc.zip gdb-ff12f303355b20de1260bc1d007f973bd02615dc.tar.gz gdb-ff12f303355b20de1260bc1d007f973bd02615dc.tar.bz2 |
Fri Jan 3 16:58:31 1997 Richard Henderson <rth@tamu.edu>
elf64-alpha multiple .got rewrite:
* elf-bfd.h (struct elf_backend_data): Add always_size_sections entry.
(bfd_elf*_mkobject): Don't define here ...
* elfxx-target.h: ... but rather here. Default always_size_sections
hook to NULL.
* elf.c (elf_mkobject): Rename to bfd_elf_mkobject, since that was
what the #defines in elf-bfd.h transmuted it to anyway.
* section.c: Add SEC_LINKER_CREATED flag.
* bfd-in2.h: Rebuild.
* elf32-i386.c (elf_i386_check_relocs): Add SEC_LINKER_CREATED to
relocation section flags.
(elf_i386_size_dynamic_sections): Use SEC_LINKER_CREATED instead of
SEC_IN_MEMORY to recognize generated bits.
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_size_dynamic_sections):
Likewise.
* elf32-mips.c (mips_elf_final_link, mips_elf_create_dynamic_sections,
mips_elf_create_compact_rel_section, mips_elf_create_got_section,
mips_elf_check_relocs, mips_elf_size_dynamic_sections): Likewise.
* elf32-ppc.c (ppc_elf_create_linker_section,
ppc_elf_size_dynamic_sections): Likewise.
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_size_dynamic_sections): Likewise.
* elflink.c (_bfd_elf_create_got_section): Add SEC_LINKER_CREATED to
section flags.
(_bfd_elf_create_dynamic_sections): Likewise.
(_bfd_elf_make_linker_section_rela): Likewise.
* elflink.h (elf_link_create_dynamic_sections): Likewise.
(bfd_elf,size_dynamic_sections): Call the always_size_sections hook.
(elf_bfd_final_link): Use SEC_LINKER_CREATED instead of SEC_IN_MEMORY
to identify generated bits.
(elf_link_input_bfd): Likewise.
* elf64-alpha.c: Rewrite everything touching relocations.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 00e840c..4f7facf 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -38,7 +38,8 @@ _bfd_elf_create_got_section (abfd, info) if (bfd_get_section_by_name (abfd, ".got") != NULL) return true; - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED); s = bfd_make_section (abfd, ".got"); if (s == NULL @@ -72,6 +73,8 @@ _bfd_elf_create_got_section (abfd, info) && ! _bfd_elf_link_record_dynamic_symbol (info, h)) return false; + elf_hash_table (info)->hgot = h; + /* The first three global offset table entries are reserved. */ s->_raw_size += 3 * 4; @@ -93,7 +96,8 @@ _bfd_elf_create_dynamic_sections (abfd, info) /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and .rel[a].bss sections. */ - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED); s = bfd_make_section (abfd, ".plt"); if (s == NULL @@ -226,7 +230,6 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults) if (!lsect) { asection *s; - static elf_linker_section_t zero_section; lsect = (elf_linker_section_t *) bfd_alloc (dynobj, sizeof (elf_linker_section_t)); @@ -238,9 +241,9 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults) /* See if the sections already exist */ lsect->section = s = bfd_get_section_by_name (dynobj, lsect->name); - if (!s) + if (!s || (s->flags & defaults->flags) != defaults->flags) { - lsect->section = s = bfd_make_section (dynobj, lsect->name); + lsect->section = s = bfd_make_section_anyway (dynobj, lsect->name); if (s == NULL) return (elf_linker_section_t *)0; @@ -284,21 +287,28 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults) lsect->sym_name, lsect->name); #endif - if (!(_bfd_generic_link_add_one_symbol (info, - abfd, - lsect->sym_name, - BSF_GLOBAL, - s, - ((lsect->hole_size) - ? s->_raw_size - lsect->hole_size + lsect->sym_offset - : lsect->sym_offset), - (const char *) NULL, - false, - get_elf_backend_data (abfd)->collect, - (struct bfd_link_hash_entry **) &h))) + h = (struct elf_link_hash_entry *) + bfd_link_hash_lookup (info->hash, lsect->sym_name, false, false, false); + + if ((h == NULL || h->root.type == bfd_link_hash_undefined) + && !(_bfd_generic_link_add_one_symbol (info, + abfd, + lsect->sym_name, + BSF_GLOBAL, + s, + ((lsect->hole_size) + ? s->_raw_size - lsect->hole_size + lsect->sym_offset + : lsect->sym_offset), + (const char *) NULL, + false, + get_elf_backend_data (abfd)->collect, + (struct bfd_link_hash_entry **) &h))) return (elf_linker_section_t *)0; - h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_DYNAMIC; + if ((defaults->which != LINKER_SECTION_SDATA) + && (defaults->which != LINKER_SECTION_SDATA2)) + h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_DYNAMIC; + h->type = STT_OBJECT; lsect->sym_hash = h; @@ -359,6 +369,7 @@ _bfd_elf_make_linker_section_rela (dynobj, lsect, alignment) | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, lsect->rel_section, alignment)) return false; @@ -366,4 +377,3 @@ _bfd_elf_make_linker_section_rela (dynobj, lsect, alignment) return true; } - |