> Date: Wed, 21 Sep 2016 11:00:49 +0200
> From: Joerg Sonnenberger <jo...@bec.de>
> On Wed, Sep 21, 2016 at 10:10:43AM +0200, Mark Kettenis wrote:
> > 1. In GNU as, .align 0 is equivalent to .align 2, but with clang's
> > internal assembler .align 0 means "no alignment".
> It might be even better to use .balign or .p2align.
Perhaps. It's annoying how .align is ambiguous and different between
systems. Don't feel like polishing that turd at this moment though.
> > 2. Using "ldr" to load a constant into a register is strange. It
> > works with GNU as, but not with clang.
> It should? See llvm/test/MC/ARM/ldr-pseudo.s. For small constants that
> fit into an immediate, the mov version is certainly smaller than going
> via the constant island, but the syntax should be correct.
Heh, I think I know what's going on here. GNU as defenitely optimizes
the ldr from the constant pool into a mov. Clang doesn't do this, but
the code looks correct. But the code in question lives in the sigcode
page, and some time ago Theo added code there to fill the non-code
bits of the sigcode page with an instruction that generates SIGILL.
The code that does this is overwriting the constant pool! So in the
end, using mov is the right solution.