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).

llvm-svn: 296451
This commit is contained in:
Sean Silva 2017-02-28 09:01:58 +00:00
parent 24a593fd20
commit 6ab3926ee6
1 changed files with 12 additions and 0 deletions

View File

@ -74,7 +74,19 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body, int64_t &Addend) {
}
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) +