[PATCH] D33621: Fix for -wrap linker option and LTO, PR 33145

Mikulin, Dmitry via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 18:31:52 PDT 2017


> On Jun 1, 2017, at 5:09 PM, Rafael Avila de Espindola <rafael.espindola at gmail.com> wrote:
> 
> Dmitry Mikulin via Phabricator <reviews at reviews.llvm.org> writes:
> 
> 
>> Index: lld/test/ELF/lto/wrap-2.ll
>> ===================================================================
>> --- /dev/null
>> +++ lld/test/ELF/lto/wrap-2.ll
>> @@ -0,0 +1,25 @@
>> +; REQUIRES: x86
>> +; RUN: llvm-as %s -o %t.o
>> +; RUN: llvm-as %S/Inputs/wrap-bar.ll -o %t1.o
>> +; RUN: ld.lld %t.o %t1.o -shared -o %t.so -wrap=bar
>> +; RUN: llvm-objdump -d %t.so | FileCheck %s
>> +
>> +; Make sure that calls in foo() are not eliminated and that bar is
>> +; routed to __wrap_bar and __real_bar is routed to bar.
>> +
>> +; CHECK:      foo:
>> +; CHECK-NEXT: pushq	%rax
>> +; CHECK-NEXT: callq{{.*}}<__wrap_bar>
>> +; CHECK-NEXT: callq{{.*}}<bar>
> 
> Please also check the bindings of the *bar symbols.

I added the checks.

> 
>> Index: lld/ELF/Config.h
>> ===================================================================
>> --- lld/ELF/Config.h
>> +++ lld/ELF/Config.h
>> @@ -98,6 +98,10 @@
>>   std::vector<SymbolVersion> VersionScriptGlobals;
>>   std::vector<SymbolVersion> VersionScriptLocals;
>>   std::vector<uint8_t> BuildIdVector;
>> +
>> +  // Mapping of renamed symbols to their original pre-LTO bindings.
>> +  llvm::StringMap<uint8_t> RenamedSymbols;
> 
> Do you really need to map from the symbol name? Why can't you use the
> Symbol*?
> 

Hmm… I would need to move symbol creation for __wrap and __real prior to LTO, so it may change symtab content exposed to LTO.

I’ve just tried it: it changes symbol resolutions passed to LTO because we create early undefs (I think).

StringMap shouldn’t be terrible: the number of -wrap options must be fairly limited.




More information about the llvm-commits mailing list