Index: lld/ELF/SymbolTable.cpp =================================================================== --- lld/ELF/SymbolTable.cpp +++ lld/ELF/SymbolTable.cpp @@ -161,12 +161,13 @@ Idx2 = Idx1; Idx1 = Idx3; - // Now renaming is complete. No one refers Real symbol. We could leave - // Real as-is, but if Real is written to the symbol table, that may - // contain irrelevant values. So, we copy all values from Sym to Real. - StringRef S = Real->getName(); - memcpy(Real, Sym, sizeof(SymbolUnion)); - Real->setName(S); + // Now renaming is complete, and no one refers Real symbol. We drop Real + // from the symbol table because it's useless in the output binary. + // Alternatively, we could emit Real as an alias for Sym, but that could + // degrade the user experience of some tools that can print out only one + // symbol for each location; Sym is a preferred name than Real, but they + // might print out Real instead. + Real->IsUsedInRegularObj = false; } static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) { Index: lld/test/ELF/lto/wrap-2.ll =================================================================== --- lld/test/ELF/lto/wrap-2.ll +++ lld/test/ELF/lto/wrap-2.ll @@ -32,10 +32,6 @@ ; BIND-NEXT: Value: ; BIND-NEXT: Size: ; BIND-NEXT: Binding: Local -; BIND: Name: __real_bar -; BIND-NEXT: Value: -; BIND-NEXT: Size: -; BIND-NEXT: Binding: Local ; BIND: Name: __wrap_bar ; BIND-NEXT: Value: ; BIND-NEXT: Size: Index: lld/test/ELF/wrap-no-real.s =================================================================== --- lld/test/ELF/wrap-no-real.s +++ lld/test/ELF/wrap-no-real.s @@ -20,7 +20,6 @@ // SYM: 0000000000000000 *UND* 00000000 // SYM-NEXT: 0000000000202000 .dynamic 00000000 .hidden _DYNAMIC -// SYM-NEXT: 0000000000011000 *ABS* 00000000 __real_foo // SYM-NEXT: 0000000000011010 *ABS* 00000000 __wrap_foo // SYM-NEXT: 0000000000201000 .text 00000000 _start // SYM-NEXT: 0000000000011000 *ABS* 00000000 foo Index: lld/test/ELF/wrap.s =================================================================== --- lld/test/ELF/wrap.s +++ lld/test/ELF/wrap.s @@ -33,12 +33,7 @@ // SYM2-NEXT: Other [ // SYM2-NEXT: STV_PROTECTED // SYM2-NEXT: ] -// SYM3: Name: __real_foo -// SYM3-NEXT: Value: 0x11000 -// SYM3-NEXT: Size: -// SYM3-NEXT: Binding: Global -// SYM3-NEXT: Type: None -// SYM3-NEXT: Other: 0 +// SYM3-NOT: Name: __real_foo .global _start _start: