This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: allow certain kinds of inputs to top level asm()-s

>>> On 06.07.10 at 10:37, Jakub Jelinek <> wrote:
> On Tue, Jul 06, 2010 at 09:21:56AM +0100, Jan Beulich wrote:
>> >>> On 06.07.10 at 10:12, Jakub Jelinek <> wrote:
>> > Also note that address of symbols with "i" constraint might not work on all
>> > targets, certainly won't work on many targets with -fpic/-fPIC (so the
>> > testcase needs to be guarded with { target !fpic } or something similar).
>> > It might not even work on some targets where -fpic/-fPIC is the default.
>> Hmm, that wouldn't be good - the construct ought to work regardless
>> of -fPIC imo. I have to admit that I don't see why you think this
>> wouldn't work, so any insight would be appreciated.
> How could it possibly work?
> If you have say:
> int i;
> asm (".section .rodata; foobar: .long %0; .previous" : : "i" (&i));
> you would need to emit code to get the &i value (and, the value would be in
> a register, not constant).  That's because for -fpic you need there is an
> extra indirection, you need to read i@GOT value from memory and that's the
> &i value.
> "i" constraint requires:
>         case 'i':
>           if (CONSTANT_P (op) && (! flag_pic || LEGITIMATE_PIC_OPERAND_P 
> (op)))
>             result = 1;
>           break;
> and it is target's choice what is LEGITIMATE_PIC_OPERAND_P.  "n" allows just
> constant integers.
> Sure, you could use "X" constraint in that case, do the checking on what
> operand is valid in toplevel asms separately and just let the asm writer
> deal with -fpic etc. - the user would be responsible for adding @GOT and all
> other kinds of special target stuff to actually read the value.  But then
> using say .long %0 definitely won't work in many cases, you'll need actual
> code to read the value.

Indeed I would expect the @GOT (or whatever) to be provided by
the programmer. But I agree that the test case isn't valid with -fPIC,
and hence I'll change it accordingly for a second submission (once it
is clear what other adjustments I may need to do).

Thanks, Jan

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]