Use the plt entry as the address of some symbols.
This is the function equivalent of a copy relocation.
Since functions are expected to change sizes, we cannot use copy
relocations. In situations where one would be needed, what is done
instead is:
* Create a plt entry
* Output an undefined symbol whose addr is the plt entry.
The dynamic linker makes sure any shared library uses the plt entry as
the function address.
llvm-svn: 260224
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 4b238f8..8b1c70c 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -56,9 +56,12 @@
return Out<ELFT>::Bss->getVA() + cast<DefinedCommon>(this)->OffsetInBss;
case SharedKind: {
auto *SS = cast<SharedSymbol<ELFT>>(this);
- if (SS->NeedsCopy)
+ if (!SS->NeedsCopyOrPltAddr)
+ return 0;
+ if (SS->IsFunc)
+ return getPltVA<ELFT>();
+ else
return Out<ELFT>::Bss->getVA() + SS->OffsetInBss;
- return 0;
}
case UndefinedElfKind:
case UndefinedKind: