Fix the aarch64 logic for dynamic relocations.
There is nothing aarch64 specific in here. If a symbol can be preempted,
we need to copy the full relocation to the dynamic linker.
If a symbol cannot be preempted, we can make the dynamic linker life
easier and produce a relative relocation.
This is directly equivalent to R_X86_64_64 to R_x86_64_RELATIVE
conversion.
llvm-svn: 261678
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index ab844d3..0f7edf8 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -311,16 +311,9 @@
if (handleTlsRelocation<ELFT>(Type, Body, C, RI))
continue;
- if (Target->needsDynRelative(Type)) {
- // If Body is null it means the relocation is against a local symbol
- // and thus we need to pass the local symbol index instead.
- if (Body)
- Out<ELFT>::RelaDyn->addReloc({Target->RelativeRel, &C, RI.r_offset, true,
- Body, getAddend<ELFT>(RI)});
- else
- Out<ELFT>::RelaDyn->addReloc({Target->RelativeRel, &C, RI.r_offset, false,
- SymIndex, getAddend<ELFT>(RI)});
- }
+ if (Target->needsDynRelative(Type))
+ Out<ELFT>::RelaDyn->addReloc({Target->RelativeRel, &C, RI.r_offset, true,
+ Body, getAddend<ELFT>(RI)});
// MIPS has a special rule to create GOTs for local symbols.
if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true) &&