[lld] r296451 - Comment on the typical/simple case of VA calculation
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 01:01:58 PST 2017
Author: silvas
Date: Tue Feb 28 03:01:58 2017
New Revision: 296451
URL: http://llvm.org/viewvc/llvm-project?rev=296451&view=rev
Log:
Comment on the typical/simple case of VA calculation
There are many special cases and a layer of abstraction or two in the
way, but the VA calculation in the typical case is actually very simple
and probably makes perfect sense even to somebody new to linkers.
Also, this line brings together many components and is a good place to
start understanding the linker (or improve one's existing
understanding).
Modified:
lld/trunk/ELF/Symbols.cpp
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=296451&r1=296450&r2=296451&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Feb 28 03:01:58 2017
@@ -74,7 +74,19 @@ static typename ELFT::uint getSymVA(cons
}
const OutputSection *OutSec = IS->getOutputSection<ELFT>();
+
+ // In the typical case, this is actually very simple and boils
+ // down to adding together 3 numbers:
+ // 1. The address of the output section.
+ // 2. The offset of the input section within the output section.
+ // 3. The offset within the input section (this addition happens
+ // inside InputSection::getOffset).
+ //
+ // If you understand the data structures involved with this next
+ // line (and how they get built), then you have a pretty good
+ // understanding of the linker.
uintX_t VA = (OutSec ? OutSec->Addr : 0) + IS->getOffset<ELFT>(Offset);
+
if (D.isTls() && !Config->Relocatable) {
if (!Out::TlsPhdr)
fatal(toString(D.File) +
More information about the llvm-commits
mailing list