r203052 - Construct GlobalValues with the correct linkage instead of using setLinkage.

Nick Kledzik kledzik at apple.com
Fri Sep 12 13:14:05 PDT 2014


On Sep 12, 2014, at 1:04 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:

> On 12 September 2014 16:03, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>> I can reproduce that this crashes with
>> 
>> ./bin/clang -cc1 -triple x86_64-apple-macosx -emit-llvm  ~/llvm/test.m -w
>> 
>> because it tries to declare a
>> 
>> l_OBJC_PROTOCOL_$_p1 with a weak linkage.
>> 
>> Nick, does ld64 support having undefined reference to l prefixed
>> symbols be resolved to definitions in another file?
> 
> And if it does, what happens if there is no definition? A link error
> or the symbol resolves to null?
I think you are confused by all the meanings of “weak”.   You are thinking of a weak_import which can be missing at runtime.

ObjC only uses weak-definitions which are definitions that are automatically coalesced.

ld64 does support weak-def ‘l’ symbols.  Their atoms are coalesced by name, then the name is removed in the final output.  ObjC uses this for some data structures where the ‘l’ name has the user class/protocol name embedded in it.  It is used to reduce duplication of data structures.

-Nick






More information about the cfe-commits mailing list