[PATCH, i386, Pointer Bounds Checker 30/x] Size relocation

Uros Bizjak ubizjak@gmail.com
Tue Sep 16 10:22:00 GMT 2014


On Tue, Sep 16, 2014 at 11:37 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2014-09-16 13:08 GMT+04:00 Uros Bizjak <ubizjak@gmail.com>:
>> Hello!
>>
>>> This patch adds size relocation support for i386 target.  Relocation is used to compute bounds for static objects with incomplete type.
>>>
>>> Thanks,
>>> Ilya
>>> --
>>> gcc/
>>>
>>> 2014-06-11  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>
>>>         * config/i386/i386.md (UNSPEC_SIZEOF): New.
>>>         (move_size_reloc_si): New.
>>>         (move_size_reloc_di): New.
>>>         * config/i386/predicates.md (symbol_operand): New.
>>>
>>>
>>> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
>>> index 32db2c6..5fd556b 100644
>>> --- a/gcc/config/i386/i386.md
>>> +++ b/gcc/config/i386/i386.md
>>> @@ -79,6 +79,7 @@
>>>    UNSPEC_PLTOFF
>>>    UNSPEC_MACHOPIC_OFFSET
>>>    UNSPEC_PCREL
>>> +  UNSPEC_SIZEOF
>>>
>>>    ;; Prologue support
>>>    UNSPEC_STACK_ALLOC
>>> @@ -18340,6 +18341,32 @@
>>>    "bndstx\t{%2, %3|%3, %2}"
>>>    [(set_attr "type" "mpxst")])
>>>
>>> +(define_insn "move_size_reloc_si"
>>> +  [(set (match_operand:SI 0 "register_operand" "=r")
>>> +       (unspec:SI
>>> +        [(match_operand:SI 1 "symbol_operand")]
>>> +        UNSPEC_SIZEOF))]
>>> +  "TARGET_MPX"
>>> +  "mov{l}\t{%1@SIZE, %0|%0, %1@SIZE}"
>>> +  [(set_attr "type" "imov")
>>> +   (set_attr "mode" "SI")])
>>> +
>>> +(define_insn "move_size_reloc_di"
>>> +  [(set (match_operand:DI 0 "register_operand" "=r")
>>> +       (unspec:DI
>>> +        [(match_operand:DI 1 "symbol_operand")]
>>> +        UNSPEC_SIZEOF))]
>>> +  "TARGET_64BIT && TARGET_MPX"
>>> +{
>>> +  if (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE
>>> +      || ix86_cmodel == CM_MEDIUM_PIC || ix86_cmodel == CM_LARGE_PIC)
>>> +    return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}";
>>
>> Can x86_64_immediate_operand predicate be used here?
>
> I think it cannot be used because of TLS symbols not counting as immediate.

OK, please introduce a new predicate, similar to
x86_64_immediate_operand, perhaps x86_64_immediate_size_operand, so we
can add some comments there. This will also help to macroize the insn,
x86_64_immediate_operand has !TARGET_64BIT shortcut for this case.

Uros.



More information about the Gcc-patches mailing list