[lld] 7b8fbb7 - [ELF] Simplify addCopyRelSymbol with invokeELFT. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 12 14:08:16 PST 2022
Author: Fangrui Song
Date: 2022-03-12T14:08:10-08:00
New Revision: 7b8fbb796c4d80a75e90ace31ce9047d2e05bc08
URL: https://github.com/llvm/llvm-project/commit/7b8fbb796c4d80a75e90ace31ce9047d2e05bc08
DIFF: https://github.com/llvm/llvm-project/commit/7b8fbb796c4d80a75e90ace31ce9047d2e05bc08.diff
LOG: [ELF] Simplify addCopyRelSymbol with invokeELFT. NFC
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 9dd2b195e1a2c..fa4547555b968 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -351,7 +351,7 @@ static void replaceWithDefined(Symbol &sym, SectionBase &sec, uint64_t value,
// to the variable in .bss. This kind of issue is sometimes very hard to
// debug. What's a solution? Instead of exporting a variable V from a DSO,
// define an accessor getV().
-template <class ELFT> static void addCopyRelSymbolImpl(SharedSymbol &ss) {
+template <class ELFT> static void addCopyRelSymbol(SharedSymbol &ss) {
// Copy relocation against zero-sized symbol doesn't make sense.
uint64_t symSize = ss.getSize();
if (symSize == 0 || ss.alignment == 0)
@@ -382,26 +382,6 @@ template <class ELFT> static void addCopyRelSymbolImpl(SharedSymbol &ss) {
mainPart->relaDyn->addSymbolReloc(target->copyRel, *sec, 0, ss);
}
-static void addCopyRelSymbol(SharedSymbol &ss) {
- const auto &file = cast<SharedFile>(*ss.file);
- switch (file.ekind) {
- case ELF32LEKind:
- addCopyRelSymbolImpl<ELF32LE>(ss);
- break;
- case ELF32BEKind:
- addCopyRelSymbolImpl<ELF32BE>(ss);
- break;
- case ELF64LEKind:
- addCopyRelSymbolImpl<ELF64LE>(ss);
- break;
- case ELF64BEKind:
- addCopyRelSymbolImpl<ELF64BE>(ss);
- break;
- default:
- llvm_unreachable("");
- }
-}
-
// .eh_frame sections are mergeable input sections, so their input
// offsets are not linearly mapped to output section. For each input
// offset, we need to find a section piece containing the offset and
@@ -1622,7 +1602,7 @@ void elf::postScanRelocations() {
addPltEntry(*in.plt, *in.gotPlt, *in.relaPlt, target->pltRel, sym);
if (sym.needsCopy) {
if (sym.isObject()) {
- addCopyRelSymbol(cast<SharedSymbol>(sym));
+ invokeELFT(addCopyRelSymbol, cast<SharedSymbol>(sym));
// needsCopy is cleared for sym and its aliases so that in later
// iterations aliases won't cause redundant copies.
assert(!sym.needsCopy);
More information about the llvm-commits
mailing list