GCC not calling __main()?

Rick Mann rmann@latencyzero.com
Wed Sep 12 23:27:00 GMT 2007


On Sep 12, 2007, at 1:59 PM, Rask Ingemann Lambertsen wrote:

>> Thanks for that info. If I understand it correctly, the various
>> macros need to be defined when building GCC, right (not when building
>> target code).
>
>    Yes. Most ELF targets don't use __main() while e.g. all a.out  
> targets
> must (I think).

That implies they use a different init/term method, right?

>> How do I determine how my target was built? I chose --target=arm-elf,
>> and searching in the GCC sources for macro names like
>> TARGET_ASM_NAMED_SECTION and INIT_SECTION_ASM_OP turn up nothing in
>> gcc/config/arm/elf.h. Where else should I be looking?
>
>    For ELF targets, usually gcc/config/elfos.h (which many targets  
> include
> indirectly through gcc/tm.h which lives in the build directory and  
> is set up
> in gcc/config.gcc - look for arm*-*-elf and the tm_file definition).
>
>> If I need to change the configuration, how do I do that? On the
>> configure line? Or do I pre-define some things when calling make?
>
>    Adding
>
> #undef INIT_SECTION_ASM_OP
>
> to gcc/config/arm/elf.h ought to do the trick.

Hmm. It seems that I shouldn't need to modify GCC just to get this  
support in there. Perhaps the default approach used by arm-elf is  
sufficient, and I'm just side-stepping it by having my own start.S  
file? I find it hard to believe that modifying GCC would be necessary  
just to get C++ to behave for arm-elf...

To reiterate: I don't necessarily need to call __main(), I just want  
my static objects to get constructed/destroyed.

TIA,
-- 
Rick



More information about the Gcc-help mailing list