[llvm] r263521 - [MachO] Add MachO alt-entry directive support.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 08:25:57 PDT 2016

On 22 March 2016 at 11:20, Lang Hames <lhames at gmail.com> wrote:
> Hi Rafael,
> Apologies - mis-hit the send button. Continuing on...
> My patch special-cased 'foo + 0' to behave the same as 'foo' - ld64
> recognizes aliases for the same location and treats them as one atom. We
> only need to set the alt_entry bit on 'foo + C', where C is non-zero.

But it does so in the wrong place. It doesn't handle things like A +

Codegen can just print

sym = expr

and let MC do the work. If expr is zero, no need to output the flag.
If non-zero, emit the flag.

>> As noted in the review this introduces a different bug with regards to
>> ld and llvm-mc not agreeing about which symbols are atoms.
> This is unfortunate, but the new bug is benign: at worst you get redundant
> relocations. With a bit of work in MC I can probably get rid of these too.
> The old bug was much more dangerous - you could end up with code that needed
> relocations and didn't have any.

It is still somewhat dangerous bug as people can become dependent on
it. Avoiding the relocation shouldn't be too hard, but ideally you
would avoid MC even creating new fragments. To do that, what is needed
is to add the restriction that ".alt_entry foo" comes  before "foo:".


More information about the llvm-commits mailing list