Calling constructor functions manually
"Michał Bieliński"
michal@kast.net.pl
Sat Oct 16 08:31:00 GMT 2010
Dnia 15 PaÂździernika 2010, 17:17, Pt, Ian Lance Taylor napisaÂł:
> The key is going to be to somehow get the address of the .init section.
> If you can do that, I think you can call it as though it were a
> function. If you are using a linker script, you can add a symbol
> assignment. If not, you may have to dig into the dynamic tags, perhaps
> via /proc/self/exe, to find the DT_INIT tag and call that.
Thank you very much for this tip. I managed to extract .init address by
adding "GCC_INIT = ADDR(.init)" to custom linker script. Sadly executing
.init like a function crashes program. Next I changed the symbol to point
at start of .ctors section and wrote code piece to walk it manually. This
solved my problem. All object files are now initialized. Thanks again.
--
Michal Bielinski
More information about the Gcc-help
mailing list