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 static void addCopyRelSymbolImpl(SharedSymbol &ss) { +template 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 static void addCopyRelSymbolImpl(SharedSymbol &ss) { mainPart->relaDyn->addSymbolReloc(target->copyRel, *sec, 0, ss); } -static void addCopyRelSymbol(SharedSymbol &ss) { - const auto &file = cast(*ss.file); - switch (file.ekind) { - case ELF32LEKind: - addCopyRelSymbolImpl(ss); - break; - case ELF32BEKind: - addCopyRelSymbolImpl(ss); - break; - case ELF64LEKind: - addCopyRelSymbolImpl(ss); - break; - case ELF64BEKind: - addCopyRelSymbolImpl(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(sym)); + invokeELFT(addCopyRelSymbol, cast(sym)); // needsCopy is cleared for sym and its aliases so that in later // iterations aliases won't cause redundant copies. assert(!sym.needsCopy);