[cfe-dev] Adding custom attributes/metadata to functions and globals
Félix Cloutier via cfe-dev
cfe-dev at lists.llvm.org
Mon Oct 31 19:55:33 PDT 2016
Thanks Eli! That does solve my problem.
Félix
> Le 31 oct. 2016 à 12:31:25, Friedman, Eli <efriedma at codeaurora.org> a écrit :
>
> On 10/29/2016 11:23 AM, Félix Cloutier via cfe-dev wrote:
>> Hello all,
>>
>> I'm working on a project that parses C headers with the Clang static libraries for binary program analysis purposes. I consume the AST and do not rely on codegen.
>>
>> I would love to be able to add some additional metadata to functions: specifically, the expected address of the function in the binary program. For instance:
>>
>> int foo(int bar) __attribute__((address(0xdeadbeef)));
>>
>> Attributes are especially convenient because they are easy to embed in a macro, which could end up looking like:
>>
>> int foo(int bar) ADDRESS(0xdeadbeef);
>>
>> Since this is an open-source project maintained by me only, I would prefer to not fork Clang, and just allow people to build my program with their distributions' stock Clang packages. Sadly, this apparently means that I can't use attributes for this purpose, because the valid attribute list appears to be hard-coded into Clang, and there doesn't seem to be any attribute that I can co-opt for this purpose.
>>
>> Are there extension points that I can leverage in the Clang static libraries to allow this?
>
> The "annotate" attribute (`void f() __attribute((annotate("asdf"))) {}`) takes an arbitrary string, and has no semantic effect.
>
> -Eli
>
> --
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161031/22e84fb3/attachment.html>
More information about the cfe-dev
mailing list