[llvm] r185882 - Don't run internalize if we're outputing bit-code and not an object file.
Nick Kledzik
kledzik at apple.com
Thu Aug 8 18:25:50 PDT 2013
On Aug 8, 2013, at 4:53 PM, Bill Wendling <isanbard at gmail.com> wrote:
> On Aug 8, 2013, at 10:06 AM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>> On 8 August 2013 12:46, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>>>> I don't understand: how does output format affect symbol visibility?
>>>
>>>
>>> I agree.
>>> This looks like a bug in the linker. It should be marking every symbol
>>> as needed with -r, in which case internalize is a nop.
> Okay. I reverted it for now.
>
> Nick, Do you have an opinion on whether this is a linker issue?
The linker already does tell LTO to preserve all global symbols in -r mode.
Given that the original bug involved linker private symbols (start with ‘l’), I made a test case of all combinations of weak, hidden, and linker private. I did notice that the merging of bit code files happens as if the -keep_private_externs were used, but that should not matter.
Was does seem to be the problem is that the weak bit is lost on _weak_hidden_glob and l_weak_hidden_special.
[/tmp]> cat a.c
void glob() { }
__attribute__((weak))
void weak_glob() { }
__attribute__((visibility("hidden")))
void hidden_glob() { }
__attribute__((weak, visibility("hidden")))
void weak_hidden_glob() { }
extern void special() __asm("l_special");
void special() { }
extern void weak_special() __asm("l_weak_special");
__attribute__((weak))
void weak_special() { }
extern void hidden_special() __asm("l_hidden_special");
__attribute__((visibility("hidden")))
void hidden_special() { }
extern void weak_hidden_special() __asm("l_weak_hidden_special");
__attribute__((weak, visibility("hidden")))
void weak_hidden_special() { }
[/tmp]> cc a.c -c -o a.macho.o
[/tmp]> ld -r a.macho.o -o a.macho.r.o
[/tmp]> ld -r a.macho.o -keep_private_externs -o a.macho.r.k.o
[/tmp]> nm -nm a.macho.* | grep -v .eh
a.macho.o:
0000000000000000 (__TEXT,__text) external _glob
0000000000000010 (__TEXT,__text) private external _hidden_glob
0000000000000020 (__TEXT,__text) external l_special
0000000000000030 (__TEXT,__text) private external l_hidden_special
0000000000000040 (__TEXT,__textcoal_nt) weak external _weak_glob
0000000000000050 (__TEXT,__textcoal_nt) weak private external _weak_hidden_glob
0000000000000060 (__TEXT,__textcoal_nt) weak external l_weak_special
0000000000000070 (__TEXT,__textcoal_nt) weak private external l_weak_hidden_special
a.macho.r.k.o:
0000000000000000 (__TEXT,__text) external _glob
0000000000000010 (__TEXT,__text) private external _hidden_glob
0000000000000020 (__TEXT,__text) private external l_special
0000000000000030 (__TEXT,__text) private external l_hidden_special
0000000000000040 (__TEXT,__textcoal_nt) weak external _weak_glob
0000000000000050 (__TEXT,__textcoal_nt) weak private external _weak_hidden_glob
0000000000000060 (__TEXT,__textcoal_nt) weak private external l_weak_special
0000000000000070 (__TEXT,__textcoal_nt) weak private external l_weak_hidden_special
a.macho.r.o:
0000000000000000 (__TEXT,__text) external _glob
0000000000000010 (__TEXT,__text) non-external (was a private external) _hidden_glob
0000000000000020 (__TEXT,__text) non-external (was a private external) l_special
0000000000000030 (__TEXT,__text) non-external (was a private external) l_hidden_special
0000000000000040 (__TEXT,__textcoal_nt) weak external _weak_glob
0000000000000050 (__TEXT,__textcoal_nt) non-external (was a private external) _weak_hidden_glob
0000000000000060 (__TEXT,__textcoal_nt) non-external (was a private external) l_weak_special
0000000000000070 (__TEXT,__textcoal_nt) non-external (was a private external) l_weak_hidden_special
[/tmp]> cc a.c -c -flto -o a.bitcode.o
[/tmp]> xcrun ld -r a.bitcode.o -o a.bitcode.r.o
[/tmp]> nm -nm a.bitcode.*
a.bitcode.o:
---------------- (LTO,CODE) external _glob
---------------- (LTO,CODE) private external _hidden_glob
---------------- (LTO,CODE) weak external _weak_glob
---------------- (LTO,CODE) weak private external _weak_hidden_glob
---------------- (LTO,CODE) private external l_hidden_special
---------------- (LTO,CODE) external l_special
---------------- (LTO,CODE) weak private external l_weak_hidden_special
---------------- (LTO,CODE) weak external l_weak_special
a.bitcode.r.o:
---------------- (LTO,CODE) external _glob
---------------- (LTO,CODE) private external _hidden_glob
---------------- (LTO,CODE) weak external _weak_glob
---------------- (LTO,CODE) private external _weak_hidden_glob ### <— notice weak is missing
---------------- (LTO,CODE) private external l_hidden_special
---------------- (LTO,CODE) external l_special
---------------- (LTO,CODE) private external l_weak_hidden_special ### <— notice weak is missing
---------------- (LTO,CODE) weak external l_weak_special
[/tmp]>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130808/d4ffc37d/attachment.html>
More information about the llvm-commits
mailing list