Pass an InputFile to the InputSection constructor.

This simplifies toRegularSection and reduces the noise in a followup
patch.

llvm-svn: 321240
This commit is contained in:
Rafael Espindola 2017-12-21 02:11:51 +00:00
parent abf9d6648c
commit ce3b52c186
5 changed files with 14 additions and 15 deletions

View File

@ -454,11 +454,9 @@ InputSectionBase *ObjFile<ELFT>::getRelocTarget(const Elf_Shdr &Sec) {
// Create a regular InputSection class that has the same contents
// as a given section.
InputSectionBase *toRegularSection(MergeInputSection *Sec) {
auto *Ret = make<InputSection>(Sec->Flags, Sec->Type, Sec->Alignment,
Sec->Data, Sec->Name);
Ret->File = Sec->File;
return Ret;
static InputSection *toRegularSection(MergeInputSection *Sec) {
return make<InputSection>(Sec->File, Sec->Flags, Sec->Type, Sec->Alignment,
Sec->Data, Sec->Name);
}
template <class ELFT>
@ -983,8 +981,8 @@ static ELFKind getELFKind(MemoryBufferRef MB) {
template <class ELFT> void BinaryFile::parse() {
ArrayRef<uint8_t> Data = toArrayRef(MB.getBuffer());
auto *Section =
make<InputSection>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, 8, Data, ".data");
auto *Section = make<InputSection>(nullptr, SHF_ALLOC | SHF_WRITE,
SHT_PROGBITS, 8, Data, ".data");
Sections.push_back(Section);
// For each input file foo that is embedded to a result as a binary

View File

@ -329,11 +329,12 @@ std::string InputSectionBase::getObjMsg(uint64_t Off) {
.str();
}
InputSection InputSection::Discarded(0, 0, 0, ArrayRef<uint8_t>(), "");
InputSection InputSection::Discarded(nullptr, 0, 0, 0, ArrayRef<uint8_t>(), "");
InputSection::InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
ArrayRef<uint8_t> Data, StringRef Name, Kind K)
: InputSectionBase(nullptr, Flags, Type,
InputSection::InputSection(InputFile *F, uint64_t Flags, uint32_t Type,
uint32_t Alignment, ArrayRef<uint8_t> Data,
StringRef Name, Kind K)
: InputSectionBase(F, Flags, Type,
/*Entsize*/ 0, /*Link*/ 0, /*Info*/ 0, Alignment, Data,
Name, K) {}

View File

@ -301,7 +301,7 @@ public:
// .eh_frame. It also includes the synthetic sections themselves.
class InputSection : public InputSectionBase {
public:
InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
InputSection(InputFile *F, uint64_t Flags, uint32_t Type, uint32_t Alignment,
ArrayRef<uint8_t> Data, StringRef Name, Kind K = Regular);
template <class ELFT>
InputSection(ObjFile<ELFT> &F, const typename ELFT::Shdr &Header,

View File

@ -260,8 +260,8 @@ InputSection *elf::createInterpSection() {
StringRef S = Saver.save(Config->DynamicLinker);
ArrayRef<uint8_t> Contents = {(const uint8_t *)S.data(), S.size() + 1};
auto *Sec =
make<InputSection>(SHF_ALLOC, SHT_PROGBITS, 1, Contents, ".interp");
auto *Sec = make<InputSection>(nullptr, SHF_ALLOC, SHT_PROGBITS, 1, Contents,
".interp");
Sec->Live = true;
return Sec;
}

View File

@ -36,7 +36,7 @@ class SyntheticSection : public InputSection {
public:
SyntheticSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
StringRef Name)
: InputSection(Flags, Type, Alignment, {}, Name,
: InputSection(nullptr, Flags, Type, Alignment, {}, Name,
InputSectionBase::Synthetic) {
this->Live = true;
}