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?