Don't store an Elf_Sym for most symbols.
Our symbol representation was redundant, and some times would get out of
sync. It had an Elf_Sym, but some fields were copied to SymbolBody.
Different parts of the code were checking the bits in SymbolBody and
others were checking Elf_Sym.
There are two general approaches to fix this:
* Copy the required information and don't store and Elf_Sym.
* Don't copy the information and always use the Elf_Smy.
The second way sounds tempting, but has a big problem: we would have to
template SymbolBody. I started doing it, but it requires templeting
*everything* and creates a bit chicken and egg problem at the driver
where we have to find ELFT before we can create an ArchiveFile for
example.
As much as possible I compared the test differences with what gold and
bfd produce to make sure they are still valid. In most cases we are just
adding hidden visibility to a local symbol, which is harmless.
In most tests this is a small speedup. The only slowdown was scylla
(1.006X). The largest speedup was clang with no --build-id, -O3 or
--gc-sections (i.e.: focus on the relocations): 1.019X.
llvm-svn: 265293
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 21cd720..d007739 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -72,8 +72,9 @@
}
template <class ELFT>
-typename ELFT::uint InputSectionBase<ELFT>::getOffset(const Elf_Sym &Sym) {
- return getOffset(Sym.st_value);
+typename ELFT::uint
+InputSectionBase<ELFT>::getOffset(const DefinedRegular<ELFT> &Sym) {
+ return getOffset(Sym.Value);
}
// Returns a section that Rel relocation is pointing to.
@@ -305,7 +306,7 @@
SymVA = getMipsGotVA<ELFT>(Body, SymVA, BufLoc);
else
SymVA = Body.getGotVA<ELFT>() + A;
- if (Body.IsTls)
+ if (Body.isTls())
Type = Target->getTlsGotRel(Type);
} else if (Target->isSizeRel(Type) && Body.isPreemptible()) {
// A SIZE relocation is supposed to set a symbol size, but if a symbol