Re: Calling constructor functions manually

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux