Revert "Simplify symbol computation for non alloc sections."

This reverts commit r294346. Looks like it regressed the build of
magenta.

llvm-svn: 294460
This commit is contained in:
Rafael Espindola 2017-02-08 15:19:03 +00:00
parent bb64200e16
commit ea590d91a0
2 changed files with 11 additions and 4 deletions

View File

@ -101,8 +101,12 @@ static void assignSymbol(SymbolAssignment *Cmd, typename ELFT::uint Dot = 0) {
if (auto *Body = dyn_cast<DefinedSynthetic>(Cmd->Sym)) { if (auto *Body = dyn_cast<DefinedSynthetic>(Cmd->Sym)) {
Body->Section = Cmd->Expression.Section(); Body->Section = Cmd->Expression.Section();
if (Body->Section) if (Body->Section) {
Body->Value = Cmd->Expression(Dot) - Body->Section->Addr; uint64_t VA = 0;
if (Body->Section->Flags & SHF_ALLOC)
VA = Body->Section->Addr;
Body->Value = Cmd->Expression(Dot) - VA;
}
return; return;
} }
@ -802,9 +806,12 @@ void LinkerScript<ELFT>::assignAddresses(std::vector<PhdrEntry> &Phdrs) {
} }
uintX_t MinVA = std::numeric_limits<uintX_t>::max(); uintX_t MinVA = std::numeric_limits<uintX_t>::max();
for (OutputSectionBase *Sec : *OutputSections) for (OutputSectionBase *Sec : *OutputSections) {
if (Sec->Flags & SHF_ALLOC) if (Sec->Flags & SHF_ALLOC)
MinVA = std::min<uint64_t>(MinVA, Sec->Addr); MinVA = std::min<uint64_t>(MinVA, Sec->Addr);
else
Sec->Addr = 0;
}
allocateHeaders<ELFT>(Phdrs, *OutputSections, MinVA); allocateHeaders<ELFT>(Phdrs, *OutputSections, MinVA);
} }

View File

@ -57,7 +57,7 @@ void OutputSectionBase::writeHeaderTo(typename ELFT::Shdr *Shdr) {
Shdr->sh_flags = Flags; Shdr->sh_flags = Flags;
Shdr->sh_info = Info; Shdr->sh_info = Info;
Shdr->sh_link = Link; Shdr->sh_link = Link;
Shdr->sh_addr = (Flags & SHF_ALLOC) ? Addr : 0; Shdr->sh_addr = Addr;
Shdr->sh_size = Size; Shdr->sh_size = Size;
Shdr->sh_name = ShName; Shdr->sh_name = ShName;
} }