[lld] r256369 - Split functions and add comments. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 24 00:41:14 PST 2015
Author: ruiu
Date: Thu Dec 24 02:41:12 2015
New Revision: 256369
URL: http://llvm.org/viewvc/llvm-project?rev=256369&view=rev
Log:
Split functions and add comments. NFC.
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=256369&r1=256368&r2=256369&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Dec 24 02:41:12 2015
@@ -110,6 +110,9 @@ void elf2::ObjectFile<ELFT>::parse(Dense
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>::initializeS
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();
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=256369&r1=256368&r2=256369&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Thu Dec 24 02:41:12 2015
@@ -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);
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=256369&r1=256368&r2=256369&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Dec 24 02:41:12 2015
@@ -1453,9 +1453,14 @@ bool MipsTargetInfo<ELFT>::isRelRelative
}
}
+// _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>();
More information about the llvm-commits
mailing list