Remove Offset from Common.

It is not needed since it is always 0.

llvm-svn: 313076
This commit is contained in:
Rafael Espindola 2017-09-12 21:19:09 +00:00
parent 80b806bf30
commit 67df57a242
4 changed files with 5 additions and 5 deletions

View File

@ -872,7 +872,7 @@ ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) {
if (auto *D = dyn_cast<DefinedRegular>(B))
return {D->Section, D->Value, Loc};
if (auto *C = dyn_cast<DefinedCommon>(B))
return {C->Section, C->Offset, Loc};
return {C->Section, 0, Loc};
}
error(Loc + ": symbol not found: " + S);
return 0;

View File

@ -103,8 +103,7 @@ static uint64_t getSymVA(const SymbolBody &Body, int64_t &Addend) {
if (!Config->DefineCommon)
return 0;
auto DC = cast<DefinedCommon>(Body);
return DC.Section->getParent()->Addr + DC.Section->OutSecOff +
DC.Offset;
return DC.Section->getParent()->Addr + DC.Section->OutSecOff;
}
case SymbolBody::SharedKind: {
auto &SS = cast<SharedSymbol>(Body);

View File

@ -172,7 +172,6 @@ public:
// The output offset of this common symbol in the output bss.
// Computed by the writer.
uint64_t Offset;
uint64_t Size;
BssSection *Section = nullptr;
};

View File

@ -65,7 +65,9 @@ std::vector<InputSection *> elf::createCommonSections() {
continue;
Sym->Section = make<BssSection>("COMMON");
Sym->Offset = Sym->Section->reserveSpace(Sym->Size, Sym->Alignment);
size_t Pos = Sym->Section->reserveSpace(Sym->Size, Sym->Alignment);
assert(Pos == 0);
(void)Pos;
Sym->Section->File = Sym->getFile();
Ret.push_back(Sym->Section);
}