Re: what happens before main()?

Shantonu Sen <[email protected]> Tue, 27 Apr 2010 07:35:50 -0700
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
I don't think that would help. The kernel hands off control to dyld (the dynamic linker), which is in charge of mapping all shared libraries, as well as running initializers (including C++ static initializers). dyld then jumps to crt1.o's entry point, which may do some further initialization before entering main().

Try looking at the dyld(1) man page. DYLD_PRINT_INITIALIZERS and DYLD_PRINT_STATISTICS might be enlightening

Shantonu

Sent from my MacBook

On Apr 27, 2010, at 3:42 AM, Ivan Ostres wrote:

> Hi!
> 
> To every C/C++ program, startup file is added - like /usr/lib/crt1.o which does initializations. Since it was not compiled with -g, you can't really step through it but you could find source for it (if available) and compile it yourself and add it to your program instead of standard crt*.o. In that case you could step through it.
> 
> Regards,
> Ivan
> 
> P.S. You can check gcc/ld documentation which exact startup file is linked to your program to be sure
> 
> 
> On Apr 27, 2010, at 11:59 AM, Aya Koshigaya wrote:
> 
>> Hi,
>> 
>> I have a big library written in C++, in this lib there are several static-things that get initialised at the start of the Programm, even before the main() function is called.
>> 
>> So far so good, but the problem is - the program takes some time to start, and when I did some time-trackings to see where the time goes, I found out it takes already up to 3 seconds until my main() function is called.
>> 
>> But, since there are about 300-400 Files it would take forever to find the "bad" statics.. so, is there any way in Xcode to step trough the initialisation process? Like as if I'd put a breakpoint in the main() function and step forward.. but in the main method it's already to late :(
>> 
>> Aya~_______________________________________________
>> MacOSX-dev mailing list
>> [email protected]
>> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>> 
> 
> _______________________________________________
> MacOSX-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.