[LLVMdev] [RFC] Alias should not point to declarations

Rafael Espíndola
Wed, 30 Oct 2013 20:59:40 -0000

On 30 October 2013 16:16, Tim Northover <t.p.northover at gmail.com>
wrote:
> Hi Rafael,
>
>> With all that in mind, the attached patch changes the verifier to
>> reject aliases to declarations and updates that language reference.
>
> MachO has an R_INDR (== "indirect") symbol flag/type that (from
my
> understanding) exactly reflects this. The linker is supposed to record
> the alias and define both symbols when the referee is defined. In
> fact, I've been working on exposing this to C code very recently so
> I'd obviously quite like it to stick around.
>
> Currently I've not submitted a patch because, even though it's
> documented, ld64 doesn't have support just yet so I can't actually
> test things properly.
>
> I think the only benefit is going to be to compile-time and
> source-structure, but it would still be a shame to lose it when LLVM
> is so close to having the ideal model right now.

We chatted a bit or IRC and it does look like N_INDR  has the
behaviour of llvm aliases. An alias to a declaration is a definition
for example. It is documented here:
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html

I will try to make the ELF/COFF restrictions explicit with errors in
codegen instead.

Cheers,
Rafael