Hacker News new | ask | show | jobs
by revelation 4843 days ago
main is probably the only symbol this works with, data is generally put into non-executable sections/pages.
1 comments

Others will probably be possible, albeit compiler-specific. The IBM xlc compiler / linker chooses to implement C static initializers by simply prefixing them with __sinit_, which tells the linker to automatically glue a call to it into init before calling main. I haven't tried this specific trick in combination with that, but if I had to make a bet it would work exactly the same way.