parent
3bfaba928f
commit
3f11c8c97e
|
@ -110,6 +110,9 @@ void elf2::ObjectFile<ELFT>::parse(DenseSet<StringRef> &Comdats) {
|
|||
initializeSymbols();
|
||||
}
|
||||
|
||||
// Sections with SHT_GROUP and comdat bits define comdat section groups.
|
||||
// They are identified and deduplicated by group name. This function
|
||||
// returns a group name.
|
||||
template <class ELFT>
|
||||
StringRef ObjectFile<ELFT>::getShtGroupSignature(const Elf_Shdr &Sec) {
|
||||
const ELFFile<ELFT> &Obj = this->ELFObj;
|
||||
|
@ -222,27 +225,36 @@ void elf2::ObjectFile<ELFT>::initializeSections(DenseSet<StringRef> &Comdats) {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
ErrorOr<StringRef> NameOrErr = this->ELFObj.getSectionName(&Sec);
|
||||
error(NameOrErr);
|
||||
StringRef Name = *NameOrErr;
|
||||
if (Name == ".note.GNU-stack")
|
||||
Sections[I] = &InputSection<ELFT>::Discarded;
|
||||
else if (Name == ".eh_frame")
|
||||
Sections[I] =
|
||||
new (this->EHAlloc.Allocate()) EHInputSection<ELFT>(this, &Sec);
|
||||
else if (Config->EMachine == EM_MIPS && Name == ".reginfo")
|
||||
Sections[I] =
|
||||
new (this->Alloc) MipsReginfoInputSection<ELFT>(this, &Sec);
|
||||
else if (shouldMerge<ELFT>(Sec))
|
||||
Sections[I] =
|
||||
new (this->MAlloc.Allocate()) MergeInputSection<ELFT>(this, &Sec);
|
||||
else
|
||||
Sections[I] = new (this->Alloc) InputSection<ELFT>(this, &Sec);
|
||||
break;
|
||||
Sections[I] = createInputSection(Sec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class ELFT> InputSectionBase<ELFT> *
|
||||
elf2::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
|
||||
ErrorOr<StringRef> NameOrErr = this->ELFObj.getSectionName(&Sec);
|
||||
error(NameOrErr);
|
||||
StringRef Name = *NameOrErr;
|
||||
|
||||
// .note.GNU-stack is a marker section to control the presence of
|
||||
// PT_GNU_STACK segment in outputs. Since the presence of the segment
|
||||
// is controlled only by the command line option (-z execstack) in LLD,
|
||||
// .note.GNU-stack is ignored.
|
||||
if (Name == ".note.GNU-stack")
|
||||
return &InputSection<ELFT>::Discarded;
|
||||
|
||||
// A MIPS object file has a special section that contains register
|
||||
// usage info, which needs to be handled by the linker specially.
|
||||
if (Config->EMachine == EM_MIPS && Name == ".reginfo")
|
||||
return new (this->Alloc) MipsReginfoInputSection<ELFT>(this, &Sec);
|
||||
|
||||
if (Name == ".eh_frame")
|
||||
return new (this->EHAlloc.Allocate()) EHInputSection<ELFT>(this, &Sec);
|
||||
if (shouldMerge<ELFT>(Sec))
|
||||
return new (this->MAlloc.Allocate()) MergeInputSection<ELFT>(this, &Sec);
|
||||
return new (this->Alloc) InputSection<ELFT>(this, &Sec);
|
||||
}
|
||||
|
||||
template <class ELFT> void elf2::ObjectFile<ELFT>::initializeSymbols() {
|
||||
this->initStringTable();
|
||||
Elf_Sym_Range Syms = this->getNonLocalSymbols();
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
private:
|
||||
void initializeSections(llvm::DenseSet<StringRef> &Comdats);
|
||||
void initializeSymbols();
|
||||
InputSectionBase<ELFT> *createInputSection(const Elf_Shdr &Sec);
|
||||
|
||||
SymbolBody *createSymbolBody(StringRef StringTable, const Elf_Sym *Sym);
|
||||
|
||||
|
|
|
@ -1453,9 +1453,14 @@ bool MipsTargetInfo<ELFT>::isRelRelative(uint32_t Type) const {
|
|||
}
|
||||
}
|
||||
|
||||
// _gp is a MIPS-specific ABI-defined symbol which points to
|
||||
// a location that is relative to GOT. This function returns
|
||||
// the value for the symbol.
|
||||
template <class ELFT> typename ELFFile<ELFT>::uintX_t getMipsGpAddr() {
|
||||
const unsigned GPOffset = 0x7ff0;
|
||||
return Out<ELFT>::Got->getVA() ? (Out<ELFT>::Got->getVA() + GPOffset) : 0;
|
||||
unsigned GPOffset = 0x7ff0;
|
||||
if (uint64_t V = Out<ELFT>::Got->getVA())
|
||||
return V + GPOffset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t getMipsGpAddr<ELF32LE>();
|
||||
|
|
Loading…
Reference in New Issue