[lld] r294346 - Simplify symbol computation for non alloc sections.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 7 12:22:04 PST 2017
Author: rafael
Date: Tue Feb 7 14:22:04 2017
New Revision: 294346
URL: http://llvm.org/viewvc/llvm-project?rev=294346&view=rev
Log:
Simplify symbol computation for non alloc sections.
We now just keep the address the section would have if it was
allocatable. Only the writer ignores it at the very end.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/OutputSections.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=294346&r1=294345&r2=294346&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Feb 7 14:22:04 2017
@@ -101,12 +101,8 @@ static void assignSymbol(SymbolAssignmen
if (auto *Body = dyn_cast<DefinedSynthetic>(Cmd->Sym)) {
Body->Section = Cmd->Expression.Section();
- if (Body->Section) {
- uint64_t VA = 0;
- if (Body->Section->Flags & SHF_ALLOC)
- VA = Body->Section->Addr;
- Body->Value = Cmd->Expression(Dot) - VA;
- }
+ if (Body->Section)
+ Body->Value = Cmd->Expression(Dot) - Body->Section->Addr;
return;
}
@@ -802,12 +798,9 @@ void LinkerScript<ELFT>::assignAddresses
}
uintX_t MinVA = std::numeric_limits<uintX_t>::max();
- for (OutputSectionBase *Sec : *OutputSections) {
+ for (OutputSectionBase *Sec : *OutputSections)
if (Sec->Flags & SHF_ALLOC)
MinVA = std::min<uint64_t>(MinVA, Sec->Addr);
- else
- Sec->Addr = 0;
- }
allocateHeaders<ELFT>(Phdrs, *OutputSections, MinVA);
}
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=294346&r1=294345&r2=294346&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Feb 7 14:22:04 2017
@@ -57,7 +57,7 @@ void OutputSectionBase::writeHeaderTo(ty
Shdr->sh_flags = Flags;
Shdr->sh_info = Info;
Shdr->sh_link = Link;
- Shdr->sh_addr = Addr;
+ Shdr->sh_addr = (Flags & SHF_ALLOC) ? Addr : 0;
Shdr->sh_size = Size;
Shdr->sh_name = ShName;
}
More information about the llvm-commits
mailing list