I just saw that I sent this email to the wrong mailing list. So I reforward to gcc@gcc.gnu.org
Hi,

I am currently working on having GCC 4.1 working on mingw with ZCX exceptions and I got the following issue with Ada and the constructors:

On windows a __main function in charge of calling the constructors (so that register_frame_info is called) is used. This function is called by main and the call is added by expand_main_function in function.c.

expand_main_function is called in tree_expand_cfg (cfgexpand.c) only if the current function is the main one :

...
/* If this function is `main', emit a call to `__main'
    to run global initializers, etc.  */
 if (DECL_NAME (current_function_decl)
     && MAIN_NAME_P (DECL_NAME (current_function_decl))
     && DECL_FILE_SCOPE_P (current_function_decl))
   expand_main_function ();
...

The issue in Ada is that the result of DECL_NAME for the main function is not "main" but somethind like "_ada_main__main" because the main function is in a package called ada_main (generated by the binder).

The consequence is that expand_main_function will never be called (and so my exception tables not registered :-().

Using DECL_ASSEMBLER_NAME instead of DECL_NAME solves the issue as the exported name of that function will be "main".

Is this change seems reasonable ?
(If yes I will do a complete test before submiting the patch)

Note that this affect potentially all the platforms that use __main to call the constructors (so I think mainly non elf platforms ..).

Thanks in advance for your answers

Nicolas



Mike Stump wrote:
On Mar 24, 2006, at 3:40 AM, Nicolas Roche wrote:
Using DECL_ASSEMBLER_NAME instead of DECL_NAME solves the issue as the exported name of that function will be "main".

Careful; on some systems name it _main. But on others, you don't want _main.

Well it works even in that case as my test was done on Mingw wich use _main and not main.

Nicolas



Reply via email to