// aarch64.cc -- aarch64 target support for gold.
-// Copyright (C) 2014-2019 Free Software Foundation, Inc.
+// Copyright (C) 2014-2024 Free Software Foundation, Inc.
// Written by Jing Yu <jingyu@google.com> and Han Shen <shenhan@google.com>.
// This file is part of gold.
aarch64_valid_for_adrp_p(AArch64_address location, AArch64_address dest)
{
typedef AArch64_relocate_functions<size, big_endian> Reloc;
- int64_t adrp_imm = (Reloc::Page(dest) - Reloc::Page(location)) >> 12;
+ int64_t adrp_imm = Reloc::Page (dest) - Reloc::Page (location);
+ adrp_imm = adrp_imm < 0 ? ~(~adrp_imm >> 12) : adrp_imm >> 12;
return adrp_imm >= MIN_ADRP_IMM && adrp_imm <= MAX_ADRP_IMM;
}
Section_id_hash> AArch64_input_section_map;
typedef AArch64_insn_utilities<big_endian> Insn_utilities;
const static int TCB_SIZE = size / 8 * 2;
+ static const Address invalid_address = static_cast<Address>(-1);
Target_aarch64(const Target::Target_info* info = &aarch64_info)
: Sized_target<size, big_endian>(info),
gold_error(_("%s: unsupported reloc %u in pos independent link."),
object->name().c_str(), r_type);
}
+ // Make a PLT entry if necessary.
+ if (gsym->needs_plt_entry())
+ {
+ target->make_plt_entry(symtab, layout, gsym);
+ // Since this is not a PC-relative relocation, we may be
+ // taking the address of a function. In that case we need to
+ // set the entry in the dynamic symbol table to the address of
+ // the PLT entry.
+ if (gsym->is_from_dynobj() && !parameters->options().shared())
+ gsym->set_needs_dynsym_value();
+ }
break;
case elfcpp::R_AARCH64_LD_PREL_LO19: // 273
? NULL
: this->plt_->rela_plt());
layout->add_target_dynamic_tags(false, this->got_plt_, rel_plt,
- this->rela_dyn_, true, false);
+ this->rela_dyn_, true, false, false);
// Emit any relocs we saved in an attempt to avoid generating COPY
// relocs.
gold_assert(sh_type == elfcpp::SHT_RELA);
+ if (offset_in_output_section == this->invalid_address)
+ {
+ const Output_relaxed_input_section *poris
+ = output_section->find_relaxed_input_section(relinfo->object,
+ relinfo->data_shndx);
+ if (poris != NULL)
+ {
+ Address section_address = poris->address();
+ section_size_type section_size = poris->data_size();
+
+ gold_assert(section_address >= view_address
+ && (section_address + section_size
+ <= view_address + view_size));
+
+ off_t offset = section_address - view_address;
+ view += offset;
+ view_address += offset;
+ view_size = section_size;
+ }
+ }
+
gold::relocate_relocs<size, big_endian, Classify_reloc>(
relinfo,
prelocs,