Create an instance of Target after reading all input files. NFC.

This change itself doesn't mean anything, but it helps D59780 because
in patch, we don't know whether we need to create a CET-aware PLT or
not until we read all input files.

llvm-svn: 357194
This commit is contained in:
Rui Ueyama
2019-03-28 17:38:53 +00:00
parent 8521ba37d7
commit f28825bc06
5 changed files with 26 additions and 19 deletions

View File

@@ -214,17 +214,24 @@ void elf::addReservedSymbols() {
// 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