This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Issue with main function expansion and Ada
- From: Nicolas Roche <roche at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 24 Mar 2006 12:40:33 +0100
- Subject: Issue with main function expansion and Ada
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