PPC::PPC() {
NoneRel = R_PPC_NONE;
- GotBaseSymOff = 0x8000;
GotBaseSymInGotPlt = false;
}
PltEntrySize = 4;
GotPltEntrySize = 8;
GotBaseSymInGotPlt = false;
- GotBaseSymOff = 0x8000;
GotHeaderEntriesNum = 1;
GotPltHeaderEntriesNum = 2;
PltHeaderSize = 60;
// Do actual linking. Note that when this function is called,
// all linker scripts have already been parsed.
template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
- Target = getTarget();
-
- Config->MaxPageSize = getMaxPageSize(Args);
- Config->ImageBase = getImageBase(Args);
-
// If a -hash-style option was not given, set to a default value,
// which varies depending on the target.
if (!Args.hasArg(OPT_hash_style)) {
// We do not want to emit debug sections if --strip-all
// or -strip-debug are given.
- if (Config->Strip != StripPolicy::None)
+ if (Config->Strip != StripPolicy::None) {
llvm::erase_if(InputSections, [](InputSectionBase *S) {
return S->Name.startswith(".debug") || S->Name.startswith(".zdebug");
});
+ }
+ // The Target instance handles target-specific stuff, such as applying
+ // relocations or writing a PLT section. It also contains target-dependent
+ // values such as a default image base address.
+ Target = getTarget();
+
+ Config->EFlags = Target->calcEFlags();
Config->EFlags = Target->calcEFlags();
+ Config->MaxPageSize = getMaxPageSize(Args);
+ Config->ImageBase = getImageBase(Args);
if (Config->EMachine == EM_ARM) {
// FIXME: These warnings can be removed when lld only uses these features
uint64_t getImageBase() const;
- // Offset of _GLOBAL_OFFSET_TABLE_ from base of .got or .got.plt section.
- uint64_t GotBaseSymOff = 0;
// True if _GLOBAL_OFFSET_TABLE_ is relative to .got.plt, false if .got.
bool GotBaseSymInGotPlt = true;
// the .got section.
// We do not allow _GLOBAL_OFFSET_TABLE_ to be defined by input objects as the
// correctness of some relocations depends on its value.
- StringRef GotTableSymName =
+ StringRef GotSymName =
(Config->EMachine == EM_PPC64) ? ".TOC." : "_GLOBAL_OFFSET_TABLE_";
- if (Symbol *S = Symtab->find(GotTableSymName)) {
- if (S->isDefined())
+
+ if (Symbol *S = Symtab->find(GotSymName)) {
+ if (S->isDefined()) {
error(toString(S->File) + " cannot redefine linker defined symbol '" +
- GotTableSymName + "'");
- else
- ElfSym::GlobalOffsetTable = Symtab->addDefined(
- GotTableSymName, STV_HIDDEN, STT_NOTYPE, Target->GotBaseSymOff,
- /*Size=*/0, STB_GLOBAL, Out::ElfHeader,
- /*File=*/nullptr);
+ GotSymName + "'");
+ return;
+ }
+
+ uint64_t GotOff = 0;
+ if (Config->EMachine == EM_PPC || Config->EMachine == EM_PPC64)
+ GotOff = 0x8000;
+
+ ElfSym::GlobalOffsetTable =
+ Symtab->addDefined(GotSymName, STV_HIDDEN, STT_NOTYPE, GotOff,
+ /*Size=*/0, STB_GLOBAL, Out::ElfHeader,
+ /*File=*/nullptr);
}
// __ehdr_start is the location of ELF file headers. Note that we define