diff options
Diffstat (limited to 'bfd/elf64-alpha.c')
-rw-r--r-- | bfd/elf64-alpha.c | 74 |
1 files changed, 28 insertions, 46 deletions
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 70642a3c008..ac7ada24534 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -1204,26 +1204,23 @@ static bfd_boolean elf64_alpha_create_got_section (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) { + flagword flags; asection *s; - if ((s = bfd_get_section_by_name (abfd, ".got"))) - { - /* Check for a non-linker created .got? */ - if (alpha_elf_tdata (abfd)->got == NULL) - alpha_elf_tdata (abfd)->got = s; - return TRUE; - } - - s = bfd_make_section_with_flags (abfd, ".got", (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED)); + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED); + s = bfd_make_section_anyway_with_flags (abfd, ".got", flags); if (s == NULL || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; alpha_elf_tdata (abfd)->got = s; + /* Make sure the object's gotobj is set to itself so that we default + to every object with its own .got. We'll merge .gots later once + we've collected each object's info. */ + alpha_elf_tdata (abfd)->gotobj = abfd; + return TRUE; } @@ -1233,18 +1230,16 @@ static bfd_boolean elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) { asection *s; + flagword flags; struct elf_link_hash_entry *h; struct bfd_link_hash_entry *bh; /* We need to create .plt, .rela.plt, .got, and .rela.got sections. */ - s = bfd_make_section_with_flags (abfd, ".plt", - (SEC_ALLOC | SEC_LOAD | SEC_CODE - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | (elf64_alpha_use_secureplt - ? SEC_READONLY : 0))); + flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | (elf64_alpha_use_secureplt ? SEC_READONLY : 0)); + s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 4)) return FALSE; @@ -1263,19 +1258,16 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (info->shared && ! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; - s = bfd_make_section_with_flags (abfd, ".rela.plt", - (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)); + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, ".rela.plt", flags); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 3)) return FALSE; if (elf64_alpha_use_secureplt) { - s = bfd_make_section_with_flags (abfd, ".got.plt", - SEC_ALLOC | SEC_LINKER_CREATED); + flags = SEC_ALLOC | SEC_LINKER_CREATED; + s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 3)) return FALSE; } @@ -1283,15 +1275,15 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) /* We may or may not have created a .got section for this object, but we definitely havn't done the rest of the work. */ - if (!elf64_alpha_create_got_section (abfd, info)) - return FALSE; + if (alpha_elf_tdata(abfd)->gotobj == NULL) + { + if (!elf64_alpha_create_got_section (abfd, info)) + return FALSE; + } - s = bfd_make_section_with_flags (abfd, ".rela.got", - (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)); + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, ".rela.got", flags); if (s == NULL || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; @@ -1746,7 +1738,6 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Shdr *symtab_hdr; struct alpha_elf_link_hash_entry **sym_hashes; const Elf_Internal_Rela *rel, *relend; - bfd_boolean got_created; bfd_size_type amt; if (info->relocatable) @@ -1769,7 +1760,6 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, rel_sec_name = NULL; symtab_hdr = &elf_tdata(abfd)->symtab_hdr; sym_hashes = alpha_elf_sym_hashes(abfd); - got_created = FALSE; relend = relocs + sec->reloc_count; for (rel = relocs; rel < relend; ++rel) @@ -1881,18 +1871,10 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, if (need & NEED_GOT) { - if (!got_created) + if (alpha_elf_tdata(abfd)->gotobj == NULL) { if (!elf64_alpha_create_got_section (abfd, info)) return FALSE; - - /* Make sure the object's gotobj is set to itself so - that we default to every object with its own .got. - We'll merge .gots later once we've collected each - object's info. */ - alpha_elf_tdata(abfd)->gotobj = abfd; - - got_created = 1; } } |