[PATCH] Add an option to allow JumpInstrTables to set unnamed_addr and jumptable on all address-taken functions

Tom Roeder tmroeder at google.com
Thu Jun 19 10:05:03 PDT 2014


On Wed, Jun 18, 2014 at 11:50 PM, Nick Lewycky <nicholas at mxc.ca> wrote:
> Tom Roeder wrote:
>>
>> On Wed, Jun 18, 2014 at 12:00 AM, Nick Lewycky<nicholas at mxc.ca>  wrote:
>>>
>>> Tom Roeder wrote:
>>>>
>>>>
>>>> This small patch adds a new command flag -jump-table-all and an
>>>> associated
>>>> TargetOptions field JumpTableAll, and it modifies JumpInstrTables to add
>>>> unnamed_addr and jumptable to all address-taken functions if the flag is
>>>> set.
>>>>
>>>> This is important for applications like my implementation of
>>>> control-flow
>>>> integrity, which want to operate over all address-taken functions and
>>>> not
>>>> just the ones that happened to have been marked jumptable.
>>>
>>>
>>>
>>> Why aren't all functions being marked jumptable when building with CFI?
>>
>>
>> The CFI pass has to operate after the jumptable pass so it has the
>> requisite information (all the transformations performed by
>> JumpInstrTable). If I want to mark all functions jumptable, then I
>> have to do it before JumpInstrTable runs, or during. So, there has to
>> be something separate from the CFI pass itself that makes this happen.
>> I could add a separate pass, or I could make JumpInstrTables know
>> about CFI and set everything as jumptable when it sees CFI requested.
>> I thought instead it made sense to have this as a feature of
>> JumpInstrTables itself.
>
>
> I guess what I thought would happen is that you pass "-fcfi" to clang (or
> whatever frontend) and it marks everything jumptable unnamed_addr for you?
> ANd also adds the CFI pass to the pass manager?

I don't see why this should have anything to do with a front end
component, though it might make sense eventually to have a high-level
flag like that in clang that sets a lower-level flag. Currently, I
just pass flags directly to LTO through clang with

-Wl,--plugin-opt=-jump-table-type=arity

Would you be satisfied with me adding a flag in CommandFlags that was
something like -apply-cfi? This would then set all address-taken
functions to be unnamed_addr+jumptable and cause the CFI pass to run.



More information about the llvm-commits mailing list