mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-02-26 12:25:31 +00:00
gold aarch64 patch to enable linking hello_wolrd.
elfcpp/ChangeLog: 2014-08-08 Han Shen <shenhan@google.com> * aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn. 2014-08-08 Jing Yu <jingyu@google.com> Han Shen <shenhan@google.com> * Makefile.am (HFILES): Add aarch64-reloc-property.h. (DEFFILES): add aarch64-reloc.def. (TARGETSOURCES): Add aarch64-reloc-property.cc. (ALL_TARGETOBJS): Add aarch64-reloc-property.$(OBJEXT). * Makefile.in: Regenerate. * aarch64-reloc-property.cc: New file. * aarch64-reloc-property.h: New file. * aarch64-reloc.def: New file. * aarch64.cc: Include aarch64-reloc-property.h. Replace spaces with tab to make the format consistent. (Output_data_got_aarch64::symbol_table_): New method. (Target_aarch64::do_plt_address_for_global): New method. (Target_aarch64::do_plt_address_for_local): New method. (Target_aarch64::do_select_as_default_target): New method. (Target_aarch64::do_make_data_plt): New method. (Target_aarch64::make_data_plt): New method. (Output_data_plt_aarch64::has_irelative_section): New method. (Output_data_plt_aarch64::address_for_global): New method. (Output_data_plt_aarch64::address_for_local): New method. (Output_data_plt_aarch64::irelative_rel_): New parameter. (Output_data_plt_aarch64::add_entry): Implement contents. (Output_data_plt_aarch64::set_final_data_size): Fix typo. (Output_data_plt_aarch64::do_write): Remove useless got_base. Set the got_pov entry to plt0. (Output_data_plt_aarch64_standard::do_fill_first_plt_entry): Implement contents. (Output_data_plt_aarch64_standard::do_fill_plt_entry): Implement. (AArch64_howto): New struct. (aarch64_howto[]): New static const array. (AArch64_relocate_functions): New class. (Target_aarch64::Scan::get_reference_flags): Remove method. (Target_aarch64::Scan::local): Implement to support a few relocations. (Target_aarch64::Scan::global): Implement to support a few relocations. (Target_aarch64::make_plt_section): Implement contents. (Target_aarch64::make_plt_entry): Implement contents. (Target_aarch64::do_finalize_sections): Implement contents. (Target_aarch64::Relocate::relocate): Implement a few relocations. (Target_aarch64::relocate_section): Implement contents.
This commit is contained in:
parent
a957de0768
commit
9363c7c3ad
@ -1,3 +1,7 @@
|
||||
2014-08-08 Han Shen <shenhan@google.com>
|
||||
|
||||
* aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn.
|
||||
|
||||
2014-07-29 Matthew Fortune <matthew.fortune@imgtec.com>
|
||||
|
||||
* elfcpp.h (PT_MIPS_ABIFLAGS): New program header type.
|
||||
|
@ -46,7 +46,7 @@ enum
|
||||
{
|
||||
// Null relocation codes
|
||||
R_AARCH64_NONE = 0, // None
|
||||
withdrawn = 256, // Treat as R_AARCH64_NONE
|
||||
R_AARCH64_withdrawn = 256, // Treat as R_AARCH64_NONE
|
||||
|
||||
// Static relocations
|
||||
R_AARCH64_ABS64 = 257, // S + A
|
||||
|
@ -1,3 +1,45 @@
|
||||
2014-08-08 Jing Yu <jingyu@google.com>
|
||||
Han Shen <shenhan@google.com>
|
||||
|
||||
* Makefile.am (HFILES): Add aarch64-reloc-property.h.
|
||||
(DEFFILES): add aarch64-reloc.def.
|
||||
(TARGETSOURCES): Add aarch64-reloc-property.cc.
|
||||
(ALL_TARGETOBJS): Add aarch64-reloc-property.$(OBJEXT).
|
||||
* Makefile.in: Regenerate.
|
||||
* aarch64-reloc-property.cc: New file.
|
||||
* aarch64-reloc-property.h: New file.
|
||||
* aarch64-reloc.def: New file.
|
||||
* aarch64.cc: Include aarch64-reloc-property.h. Replace spaces
|
||||
with tab to make the format consistent.
|
||||
(Output_data_got_aarch64::symbol_table_): New method.
|
||||
(Target_aarch64::do_plt_address_for_global): New method.
|
||||
(Target_aarch64::do_plt_address_for_local): New method.
|
||||
(Target_aarch64::do_select_as_default_target): New method.
|
||||
(Target_aarch64::do_make_data_plt): New method.
|
||||
(Target_aarch64::make_data_plt): New method.
|
||||
(Output_data_plt_aarch64::has_irelative_section): New method.
|
||||
(Output_data_plt_aarch64::address_for_global): New method.
|
||||
(Output_data_plt_aarch64::address_for_local): New method.
|
||||
(Output_data_plt_aarch64::irelative_rel_): New parameter.
|
||||
(Output_data_plt_aarch64::add_entry): Implement contents.
|
||||
(Output_data_plt_aarch64::set_final_data_size): Fix typo.
|
||||
(Output_data_plt_aarch64::do_write): Remove useless got_base. Set
|
||||
the got_pov entry to plt0.
|
||||
(Output_data_plt_aarch64_standard::do_fill_first_plt_entry):
|
||||
Implement contents.
|
||||
(Output_data_plt_aarch64_standard::do_fill_plt_entry): Implement.
|
||||
(AArch64_howto): New struct.
|
||||
(aarch64_howto[]): New static const array.
|
||||
(AArch64_relocate_functions): New class.
|
||||
(Target_aarch64::Scan::get_reference_flags): Remove method.
|
||||
(Target_aarch64::Scan::local): Implement to support a few relocations.
|
||||
(Target_aarch64::Scan::global): Implement to support a few relocations.
|
||||
(Target_aarch64::make_plt_section): Implement contents.
|
||||
(Target_aarch64::make_plt_entry): Implement contents.
|
||||
(Target_aarch64::do_finalize_sections): Implement contents.
|
||||
(Target_aarch64::Relocate::relocate): Implement a few relocations.
|
||||
(Target_aarch64::relocate_section): Implement contents.
|
||||
|
||||
2014-08-06 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* testsuite/defsym_test.sh: Allow ppc64le localentry annotation.
|
||||
|
@ -106,6 +106,7 @@ CCFILES = \
|
||||
|
||||
HFILES = \
|
||||
arm-reloc-property.h \
|
||||
aarch64-reloc-property.h \
|
||||
archive.h \
|
||||
attributes.h \
|
||||
binary.h \
|
||||
@ -158,18 +159,18 @@ HFILES = \
|
||||
YFILES = \
|
||||
yyscript.y
|
||||
|
||||
DEFFILES = arm-reloc.def
|
||||
DEFFILES = arm-reloc.def aarch64-reloc.def
|
||||
|
||||
EXTRA_DIST = yyscript.c yyscript.h
|
||||
|
||||
TARGETSOURCES = \
|
||||
i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
|
||||
mips.cc aarch64.cc
|
||||
mips.cc aarch64.cc aarch64-reloc-property.cc
|
||||
|
||||
ALL_TARGETOBJS = \
|
||||
i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
|
||||
arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \
|
||||
mips.$(OBJEXT) aarch64.$(OBJEXT)
|
||||
mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT)
|
||||
|
||||
libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
|
||||
libgold_a_LIBADD = $(LIBOBJS)
|
||||
|
@ -477,6 +477,7 @@ CCFILES = \
|
||||
|
||||
HFILES = \
|
||||
arm-reloc-property.h \
|
||||
aarch64-reloc-property.h \
|
||||
archive.h \
|
||||
attributes.h \
|
||||
binary.h \
|
||||
@ -529,16 +530,16 @@ HFILES = \
|
||||
YFILES = \
|
||||
yyscript.y
|
||||
|
||||
DEFFILES = arm-reloc.def
|
||||
DEFFILES = arm-reloc.def aarch64-reloc.def
|
||||
EXTRA_DIST = yyscript.c yyscript.h
|
||||
TARGETSOURCES = \
|
||||
i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
|
||||
mips.cc aarch64.cc
|
||||
mips.cc aarch64.cc aarch64-reloc-property.cc
|
||||
|
||||
ALL_TARGETOBJS = \
|
||||
i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
|
||||
arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \
|
||||
mips.$(OBJEXT) aarch64.$(OBJEXT)
|
||||
mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT)
|
||||
|
||||
libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
|
||||
libgold_a_LIBADD = $(LIBOBJS)
|
||||
|
164
gold/aarch64-reloc-property.cc
Normal file
164
gold/aarch64-reloc-property.cc
Normal file
@ -0,0 +1,164 @@
|
||||
// aarch64-reloc-property.cc -- AArch64 relocation properties -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2014 Free Software Foundation, Inc.
|
||||
// Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>.
|
||||
|
||||
// This file is part of gold.
|
||||
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||
// MA 02110-1301, USA.
|
||||
|
||||
#include "gold.h"
|
||||
|
||||
#include "aarch64-reloc-property.h"
|
||||
#include "aarch64.h"
|
||||
|
||||
#include "symtab.h"
|
||||
|
||||
#include<stdio.h>
|
||||
|
||||
namespace gold
|
||||
{
|
||||
|
||||
template<int L, int U>
|
||||
bool
|
||||
rvalue_checkup(int64_t x)
|
||||
{
|
||||
// We save the extra_alignment_requirement bits on [31:16] of U.
|
||||
// "extra_alignment_requirement" could be 0, 1, 3, 7 and 15.
|
||||
unsigned short extra_alignment_requirement = (U & 0xFFFF0000) >> 16;
|
||||
// [15:0] of U indicates the upper bound check.
|
||||
int64_t u = U & 0x0000FFFF;
|
||||
if (u == 0)
|
||||
{
|
||||
// No requirement to check overflow.
|
||||
gold_assert(L == 0);
|
||||
return (x & extra_alignment_requirement) == 0;
|
||||
}
|
||||
|
||||
// Check both overflow and alignment if needed.
|
||||
int64_t low_bound = -(L == 0 ? 0 : ((int64_t)1 << L));
|
||||
int64_t up_bound = ((int64_t)1 << u);
|
||||
return ((low_bound <= x && x < up_bound)
|
||||
&& ((x & extra_alignment_requirement) == 0));
|
||||
}
|
||||
|
||||
template<>
|
||||
bool
|
||||
rvalue_checkup<0, 0>(int64_t) { return true; }
|
||||
|
||||
template<int L, int U>
|
||||
uint64_t
|
||||
rvalue_bit_select(uint64_t x)
|
||||
{
|
||||
if (U == 63) return x >> L;
|
||||
return (x & (((uint64_t)1 << (U+1)) - 1)) >> L;
|
||||
}
|
||||
|
||||
template<>
|
||||
uint64_t
|
||||
rvalue_bit_select<0, 0>(uint64_t x) { return x; }
|
||||
|
||||
AArch64_reloc_property::AArch64_reloc_property(
|
||||
unsigned int code,
|
||||
const char* name,
|
||||
Reloc_type rtype,
|
||||
Reloc_class rclass,
|
||||
bool is_implemented,
|
||||
int group_index,
|
||||
int reference_flags,
|
||||
Reloc_inst reloc_inst,
|
||||
rvalue_checkup_func_p rvalue_checkup_func,
|
||||
rvalue_bit_select_func rvalue_bit_select)
|
||||
: code_(code), name_(name), reloc_type_(rtype), reloc_class_(rclass),
|
||||
group_index_(group_index),
|
||||
is_implemented_(is_implemented),
|
||||
reference_flags_(reference_flags),
|
||||
reloc_inst_(reloc_inst),
|
||||
rvalue_checkup_func_(rvalue_checkup_func),
|
||||
rvalue_bit_select_func_(rvalue_bit_select)
|
||||
{}
|
||||
|
||||
AArch64_reloc_property_table::AArch64_reloc_property_table()
|
||||
{
|
||||
const bool Y(true), N(false);
|
||||
for (unsigned int i = 0; i < Property_table_size; ++i)
|
||||
table_[i] = NULL;
|
||||
|
||||
#define RL_CHECK_ALIGN2 (1 << 16)
|
||||
#define RL_CHECK_ALIGN4 (3 << 16)
|
||||
#define RL_CHECK_ALIGN8 (7 << 16)
|
||||
#define RL_CHECK_ALIGN16 (15 << 16)
|
||||
|
||||
#undef ARD
|
||||
#define ARD(rname, type, class, is_implemented, group_index, LB, UB, BSL, BSH, RFLAGS, inst) \
|
||||
do \
|
||||
{ \
|
||||
int tidx = code_to_array_index(elfcpp::R_AARCH64_##rname); \
|
||||
AArch64_reloc_property * p = new AArch64_reloc_property( \
|
||||
elfcpp::R_AARCH64_##rname, "R_AARCH64_" #rname, \
|
||||
AArch64_reloc_property::RT_##type, \
|
||||
AArch64_reloc_property::RC_##class, \
|
||||
is_implemented, \
|
||||
group_index, \
|
||||
(RFLAGS), \
|
||||
AArch64_reloc_property::INST_##inst, \
|
||||
rvalue_checkup<LB,UB>, \
|
||||
rvalue_bit_select<BSL,BSH>); \
|
||||
table_[tidx] = p; \
|
||||
} \
|
||||
while (0);
|
||||
#include"aarch64-reloc.def"
|
||||
#undef ARD
|
||||
}
|
||||
|
||||
// Return a string describing a relocation code that fails to get a
|
||||
// relocation property in get_implemented_static_reloc_property().
|
||||
|
||||
std::string
|
||||
AArch64_reloc_property_table::reloc_name_in_error_message(unsigned int code)
|
||||
{
|
||||
gold_assert(code < Property_table_size);
|
||||
|
||||
const AArch64_reloc_property* arp = this->table_[code];
|
||||
|
||||
if (arp == NULL)
|
||||
{
|
||||
char buffer[100];
|
||||
sprintf(buffer, _("invalid reloc %u"), code);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
// gold only implements static relocation codes.
|
||||
AArch64_reloc_property::Reloc_type reloc_type = arp->reloc_type();
|
||||
gold_assert(reloc_type == AArch64_reloc_property::RT_STATIC
|
||||
|| !arp->is_implemented());
|
||||
|
||||
const char* prefix = NULL;
|
||||
switch (reloc_type)
|
||||
{
|
||||
case AArch64_reloc_property::RT_STATIC:
|
||||
prefix = arp->is_implemented() ? _("reloc ") : _("unimplemented reloc ");
|
||||
break;
|
||||
case AArch64_reloc_property::RT_DYNAMIC:
|
||||
prefix = _("dynamic reloc ");
|
||||
break;
|
||||
default:
|
||||
gold_unreachable();
|
||||
}
|
||||
return std::string(prefix) + arp->name();
|
||||
}
|
||||
|
||||
}
|
245
gold/aarch64-reloc-property.h
Normal file
245
gold/aarch64-reloc-property.h
Normal file
@ -0,0 +1,245 @@
|
||||
// aarch64-reloc-property.h -- AArch64 relocation properties -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2014 Free Software Foundation, Inc.
|
||||
// Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>.
|
||||
|
||||
// This file is part of gold.
|
||||
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||
// MA 02110-1301, USA.
|
||||
|
||||
#ifndef GOLD_AARCH64_RELOC_PROPERTY_H
|
||||
#define GOLD_AARCH64_RELOC_PROPERTY_H
|
||||
|
||||
#include<vector>
|
||||
#include<string>
|
||||
|
||||
#include"aarch64.h"
|
||||
|
||||
namespace gold
|
||||
{
|
||||
// The AArch64_reloc_property class is to store information about a particular
|
||||
// relocation code.
|
||||
|
||||
class AArch64_reloc_property
|
||||
{
|
||||
public:
|
||||
// Types of relocation codes.
|
||||
enum Reloc_type {
|
||||
RT_NONE, // No relocation type.
|
||||
RT_STATIC, // Relocations processed by static linkers.
|
||||
RT_DYNAMIC, // Relocations processed by dynamic linkers.
|
||||
};
|
||||
|
||||
// Classes of relocation codes.
|
||||
enum Reloc_class {
|
||||
RC_NONE, // No relocation class.
|
||||
RC_DATA, // Data relocation.
|
||||
RC_AARCH64, // Static AArch64 relocations
|
||||
RC_CFLOW, // Control flow
|
||||
RC_TLS, // Thread local storage
|
||||
RC_DYNAMIC, // Dynamic relocation
|
||||
};
|
||||
|
||||
// Instructions that are associated with relocations.
|
||||
enum Reloc_inst {
|
||||
INST_DATA = 0,
|
||||
INST_MOVW = 1, // movz, movk, movn
|
||||
INST_LD = 2, // ld literal
|
||||
INST_ADR = 3, // adr
|
||||
INST_ADRP = 4, // adrp
|
||||
INST_ADD = 5, // add
|
||||
INST_LDST = 6, // ld/st
|
||||
INST_TBZNZ = 7, // tbz/tbnz
|
||||
INST_CONDB = 8, // B.cond
|
||||
INST_B = 9, // b [25:0]
|
||||
INST_CALL = 10, // bl [25:0]
|
||||
INST_NUM = 11, // total number of entries in the table
|
||||
};
|
||||
|
||||
// Types of bases of relative addressing relocation codes.
|
||||
// enum Relative_address_base {
|
||||
// RAB_NONE, // Relocation is not relative addressing
|
||||
// };
|
||||
|
||||
typedef bool (*rvalue_checkup_func_p)(int64_t);
|
||||
typedef uint64_t (*rvalue_bit_select_func)(uint64_t);
|
||||
|
||||
// Relocation code represented by this.
|
||||
unsigned int
|
||||
code() const
|
||||
{ return this->code_; }
|
||||
|
||||
// Name of the relocation code.
|
||||
const std::string&
|
||||
name() const
|
||||
{ return this->name_; }
|
||||
|
||||
// Type of relocation code.
|
||||
Reloc_type
|
||||
reloc_type() const
|
||||
{ return this->reloc_type_; }
|
||||
|
||||
// Class of relocation code.
|
||||
Reloc_class
|
||||
reloc_class() const
|
||||
{ return this->reloc_class_; }
|
||||
|
||||
// Whether this code is implemented in gold.
|
||||
bool
|
||||
is_implemented() const
|
||||
{ return this->is_implemented_; }
|
||||
|
||||
// If code is a group relocation code, return the group number, otherwise -1.
|
||||
int
|
||||
group_index() const
|
||||
{ return this->group_index_; }
|
||||
|
||||
// Return alignment of relocation.
|
||||
size_t
|
||||
align() const
|
||||
{ return this->align_; }
|
||||
|
||||
int
|
||||
reference_flags() const
|
||||
{ return this->reference_flags_; }
|
||||
|
||||
// Instruction associated with this relocation.
|
||||
Reloc_inst
|
||||
reloc_inst() const
|
||||
{ return this->reloc_inst_; }
|
||||
|
||||
// Check overflow of x
|
||||
bool checkup_x_value(int64_t x) const
|
||||
{ return this->rvalue_checkup_func_(x); }
|
||||
|
||||
// Return portions of x as is defined in aarch64-reloc.def.
|
||||
uint64_t select_x_value(uint64_t x) const
|
||||
{ return this->rvalue_bit_select_func_(x); }
|
||||
|
||||
protected:
|
||||
// These are protected. We only allow AArch64_reloc_property_table to
|
||||
// manage AArch64_reloc_property.
|
||||
AArch64_reloc_property(unsigned int code, const char* name, Reloc_type rtype,
|
||||
Reloc_class rclass,
|
||||
bool is_implemented,
|
||||
int group_index,
|
||||
int reference_flags,
|
||||
Reloc_inst reloc_inst,
|
||||
rvalue_checkup_func_p rvalue_checkup_func,
|
||||
rvalue_bit_select_func rvalue_bit_select);
|
||||
|
||||
friend class AArch64_reloc_property_table;
|
||||
|
||||
private:
|
||||
// Copying is not allowed.
|
||||
AArch64_reloc_property(const AArch64_reloc_property&);
|
||||
AArch64_reloc_property& operator=(const AArch64_reloc_property&);
|
||||
|
||||
// Relocation code.
|
||||
const unsigned int code_;
|
||||
// Relocation name.
|
||||
const std::string name_;
|
||||
// Type of relocation.
|
||||
Reloc_type reloc_type_;
|
||||
// Class of relocation.
|
||||
Reloc_class reloc_class_;
|
||||
// Group index (0, 1, or 2) if this is a group relocation or -1 otherwise.
|
||||
int group_index_;
|
||||
// Size of relocation.
|
||||
size_t size_;
|
||||
// Alignment of relocation.
|
||||
size_t align_;
|
||||
// Relative address base.
|
||||
// Relative_address_base relative_address_base_;
|
||||
// Whether this is deprecated.
|
||||
bool is_deprecated_ : 1;
|
||||
// Whether this is implemented in gold.
|
||||
bool is_implemented_ : 1;
|
||||
// Whether this checks overflow.
|
||||
bool checks_overflow_ : 1;
|
||||
const int reference_flags_;
|
||||
// Instruction associated with relocation.
|
||||
Reloc_inst reloc_inst_;
|
||||
rvalue_checkup_func_p rvalue_checkup_func_;
|
||||
rvalue_bit_select_func rvalue_bit_select_func_;
|
||||
};
|
||||
|
||||
class AArch64_reloc_property_table
|
||||
{
|
||||
public:
|
||||
AArch64_reloc_property_table();
|
||||
|
||||
const AArch64_reloc_property*
|
||||
get_reloc_property(unsigned int code) const
|
||||
{
|
||||
unsigned int idx = code_to_array_index(code);
|
||||
return this->table_[idx];
|
||||
}
|
||||
|
||||
// Like get_reloc_property but only return non-NULL if relocation code is
|
||||
// static and implemented.
|
||||
const AArch64_reloc_property*
|
||||
get_implemented_static_reloc_property(unsigned int code) const
|
||||
{
|
||||
unsigned int idx = code_to_array_index(code);
|
||||
const AArch64_reloc_property* arp = this->table_[idx];
|
||||
return ((arp != NULL
|
||||
&& (arp->reloc_type() == AArch64_reloc_property::RT_STATIC)
|
||||
&& arp->is_implemented())
|
||||
? arp
|
||||
: NULL);
|
||||
}
|
||||
|
||||
// Return a string describing the relocation code that is not
|
||||
// an implemented static reloc code.
|
||||
std::string
|
||||
reloc_name_in_error_message(unsigned int code);
|
||||
|
||||
private:
|
||||
// Copying is not allowed.
|
||||
AArch64_reloc_property_table(const AArch64_reloc_property_table&);
|
||||
AArch64_reloc_property_table& operator=(const AArch64_reloc_property_table&);
|
||||
|
||||
// Map aarch64 rtypes into range(0,300) as following
|
||||
// 256 ~ 313 -> 0 ~ 57
|
||||
// 512 ~ 573 -> 128 ~ 189
|
||||
int
|
||||
code_to_array_index(unsigned int code) const
|
||||
{
|
||||
if (code == 0) return 0;
|
||||
if (!((code >= elfcpp::R_AARCH64_ABS64 &&
|
||||
code <= elfcpp::R_AARCH64_LD64_GOTPAGE_LO15)
|
||||
|| (code >= elfcpp::R_AARCH64_TLSGD_ADR_PREL21 &&
|
||||
code <= elfcpp::R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC)))
|
||||
{
|
||||
gold_error(_("Invalid/unrecognized reloc reloc %d."), code);
|
||||
}
|
||||
unsigned int rv = -1;
|
||||
if (code & (1 << 9))
|
||||
rv = 128 + code - 512; // 512 - 573
|
||||
else if (code & (1 << 8))
|
||||
rv = code - 256; // 256 - 313
|
||||
gold_assert(rv <= Property_table_size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static const unsigned int Property_table_size = 300;
|
||||
AArch64_reloc_property* table_[Property_table_size];
|
||||
}; // End of class AArch64_reloc_property_table
|
||||
|
||||
} // End namespace gold.
|
||||
|
||||
#endif // !defined(GOLD_AARCH64_RELOC_PROPERTY_H)
|
70
gold/aarch64-reloc.def
Normal file
70
gold/aarch64-reloc.def
Normal file
@ -0,0 +1,70 @@
|
||||
// aarch64-reloc.def -- AArch64 relocation definitions.
|
||||
|
||||
// Copyright (C) 2014 Free Software Foundation, Inc.
|
||||
// Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>.
|
||||
|
||||
// This file is part of gold.
|
||||
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||
// MA 02110-1301, USA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Insn modified by relocation, see enum Reloc_inst -------------------------------------------------------------------------+
|
||||
// Symbol reference type -----------------------------------------------------------------------------+ |
|
||||
// Portion off X to retrieve -------------------------------------------------------------------+ | |
|
||||
// Checking function, see Note(A)---------------------------------------+ | | |
|
||||
// Group index---------------------------------------------------+ | | | |
|
||||
// Implemented----------------------------------------------+ | | | | |
|
||||
// Class-------------------------------------+ | | | | | |
|
||||
// Type----------------------------+ | | | | | | |
|
||||
// Name | | | | | | | |
|
||||
// | | | | | | | | |
|
||||
ARD(ABS64 , STATIC , DATA , Y, -1, 0,0 , 0,0 , Symbol::ABSOLUTE_REF , DATA )
|
||||
ARD(ABS32 , STATIC , DATA , Y, -1, 31,32 , 0,0 , Symbol::ABSOLUTE_REF , DATA )
|
||||
ARD(ABS16 , STATIC , DATA , Y, -1, 15,16 , 0,0 , Symbol::ABSOLUTE_REF , DATA )
|
||||
ARD(PREL64 , STATIC , DATA , Y, -1, 0,0 , 0,0 , Symbol::RELATIVE_REF , DATA )
|
||||
ARD(PREL32 , STATIC , DATA , Y, -1, 31,32 , 0,0 , Symbol::RELATIVE_REF , DATA )
|
||||
ARD(PREL16 , STATIC , DATA , Y, -1, 15,16 , 0,0 , Symbol::RELATIVE_REF , DATA )
|
||||
// Above is from Table 4-6, Data relocations, 257-262.
|
||||
|
||||
ARD(ADR_PREL_PG_HI21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::RELATIVE_REF , ADRP )
|
||||
ARD(ADR_PREL_PG_HI21_NC , STATIC , AARCH64 , Y, -1, 0,0 , 12,32 , Symbol::RELATIVE_REF , ADRP )
|
||||
ARD(LDST8_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(LDST16_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN2 , 1,11 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(LDST32_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN4 , 2,11 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(LDST64_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(LDST128_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN16 , 4,11 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(ADD_ABS_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD )
|
||||
ARD(ADR_GOT_PAGE , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::RELATIVE_REF , ADRP )
|
||||
ARD(LD64_GOT_LO12_NC , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(TSTBR14 , STATIC , CFLOW , N, -1, 15,15 , 2,15 , Symbol::ABSOLUTE_REF , TBZNZ )
|
||||
ARD(CONDBR19 , STATIC , CFLOW , N, -1, 20,20 , 2,20 , Symbol::ABSOLUTE_REF , CONDB )
|
||||
ARD(CALL26 , STATIC , CFLOW , Y, -1, 27,27 , 2,27 , (Symbol::FUNCTION_CALL|Symbol::RELATIVE_REF) , CALL )
|
||||
ARD(JUMP26 , STATIC , CFLOW , Y, -1, 27,27 , 2,27 , (Symbol::FUNCTION_CALL|Symbol::RELATIVE_REF) , B )
|
||||
// Above is from Table 4-10, Relocations for control-flow instructions,
|
||||
// 279-283.
|
||||
|
||||
ARD(TLSIE_MOVW_GOTTPREL_G1 , STATIC , AARCH64 , N, -1, 0,0 , 16,31 , Symbol::ABSOLUTE_REF , MOVW )
|
||||
ARD(TLSIE_MOVW_GOTTPREL_G0_NC , STATIC , AARCH64 , N, -1, 0,0 , 0,15 , Symbol::ABSOLUTE_REF , MOVW )
|
||||
ARD(TLSIE_ADR_GOTTPREL_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::ABSOLUTE_REF , ADRP )
|
||||
ARD(TLSIE_LD64_GOTTPREL_LO12_NC , STATIC , AARCH64 , N, -1, 32,32 , 12,32 , Symbol::ABSOLUTE_REF , LDST )
|
||||
ARD(TLSIE_LD_GOTTPREL_PREL19 , STATIC , AARCH64 , N, -1, 20,20 , 2,20 , Symbol::ABSOLUTE_REF , LD )
|
||||
// Above is from Table 4-17, Initial Exec TLS relocations, 539-543.
|
||||
|
||||
// Note -
|
||||
// A - Checking X, (L,U), if L == 0 && U == 0, no check. Otherwise, L!=0,
|
||||
// check that -2^L<=X<2^U. Also an extra alignment check could be embeded
|
||||
// into U.
|
1148
gold/aarch64.cc
1148
gold/aarch64.cc
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user