Attributes and static program traits

I recently came across this article about: Hotpatching a C function on x86. It’s a really cool article because it takes advantage of some compiler-specific and pretty low level stuff in order to do actual code patching on the popular x86-64 architecture.

But, if you take a look at some of the code:

__attribute__ ((ms_hook_prologue))
__attribute__ ((aligned(8)))
__attribute__ ((noinline))
__attribute__ ((noclone))
void
hello(void)
{
   __asm("");
   puts("hello");
}

Well, all those __attribute__ tags look kind of annoying.

Really–can’t there be a C-like language or some sort of meta-tool that can hook in at the language or lower level to cleanly encapsulate implementation vs. interface details?

This would also require meticulously surveying the semantics of a language and then translating into traits, but it would also give both compiler and language developers and programmers the degree of control over implementation details with clarity.

I’d imagine that maybe D or Rust might be able to do this sort of thing. Perhaps I can look into this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s