[cfe-dev] linux/i386 and mregparm

pageexec at freemail.hu pageexec at freemail.hu
Tue Mar 1 12:54:55 PST 2011


On 2 Mar 2011 at 0:08, Anton Korobeynikov wrote:

> > i'm not mixing them up in that i know they're different things, but i do
> > (want to) mix them in the sense that i'd like clang/llvm to generate PIC
> > for the kernel code model as well, as this is what gcc does.
> Then you should rely on relocation model switch, not to hack on random
> stuff around.
> Also, note that according to the ABI specification I already shown the
> link to, there is no PIC for kernel code model (see the same section
> 3.5.1).

when i said PIC, i didn't really mean the full-blown userland PIC infrastructure,
but only the use of rip relative addressing which gcc already employs for the
kernel code model as well. and to get this to work i needed a hack but if you
know where to do it properly, i'm all ears ;).

speaking of the ABI though, on the small model it says:

    This allows the compiler to encode symbolic references with offsets in
    the range from -(2^31) to 2^24 or from 0x80000000 to 0x01000000 directly
    in the sign extended immediate operands, with offsets in the range from
    0 to 2^31-2^24 or from 0x00000000 to 0x7f000000 in the zero extended
    immediate operands [...]

as you may note, the range is different for offsets that get zero extended
vs. those that get sign extended, and isOffsetSuitableForCodeModel checks
only the sign extended range (i assume it's only called for insns that do
sign extension). now if you look at the kernel code model, you'll find this:

     This code model has advantages similar to those of the small model, but
     allows encoding of zero extended symbolic references only for offsets from
     2^31 to 2^31 + 2^24 or from 0x80000000 to 0x81000000. The range offsets
     for sign extended reference changes to 0 to 2^31 + 2^24 or 0x00000000 to
     0x81000000.

once again, there're two different ranges allowed for the offset yet llvm
allows neither fully, not even the sign extended case.




More information about the cfe-dev mailing list