increase size of function pointer?

I would like to be able to increase the size allocated for normal function pointers so they each fill a entire (virtual memory) page.

The problem is I’m not entirely sure how to go about this. Is it possible to do this through the ASTConsumer(or some kind of pass) or if I would need to dig in (very) deeply with CodeGen? I’m having a rough timing figuring out how this works with LLVM/Clang and any advice would be great

Thank you

Do you mean that you want each *function* to occupy its own
VM page, or do you really mean that you want function *pointers*
to grow from 4-8 bytes apiece to 4KB?

The best way of doing the former is to specify a huge alignment for
the function. The latter is likely to break a lot of code that assumes
(yes, technically contrary to the standards) that function pointers
can be losslessly cast to, say, void*.

John.

I mean pointers to functions unfortunately. I guess this will be more interesting that I thought. Any specific advice?

Thank again

I mean pointers to functions unfortunately. I guess this will be more interesting that I thought. Any specific advice?

This makes me think of the early days of EFI on the Intel(r) Itanium(r) Processors. An indirect procedure call on Itanium is through a Plabel. So a function pointer points to a Plabel that contains the function address and a value to load into the gp register.

Maybe you could make the first 4-8 bytes of the 4K page contain the pointer to the function, and make the code gen for function calls indirect the extra layer. You would end up needing relocations for both the “Plabel” and the function pointer, which should not be a big deal, but could really confuse what ever linker you are using. This would solve the cast to void* issue, but could create its own set of issues?

Some one else would need to comment on how practical this would be… Good luck.

Andrew Fish

What's your overall goal? If you want to be able to use page
protection to detect calls through function pointers, it seems like a
dynamic instrumentation tool like Pin or DynamoRIO would be a better
way to go. Just find all indirect call instructions and instrument
them.

Reid