Commit d6cf3187 by Richard Stallman

(NAME__MAIN, SYMBOL__MAIN): Add default definitions.

(write_c_file, scan_prog_file(OSF/ROSE)): Use them instead of explicit
__main.

From-SVN: r4990
parent d3984356
...@@ -149,6 +149,16 @@ extern int errno; ...@@ -149,6 +149,16 @@ extern int errno;
#endif #endif
#endif /* OBJECT_FORMAT_NONE */ #endif /* OBJECT_FORMAT_NONE */
/* Some systems use __main in a way incompatible with its use in gcc, in these
cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
give the same symbol without quotes for an alternative entry point. You
must define both, or niether. */
#ifndef NAME__MAIN
#define NAME__MAIN "__main"
#define SYMBOL__MAIN __main
#endif
/* Linked lists of constructor and destructor names. */ /* Linked lists of constructor and destructor names. */
...@@ -1297,8 +1307,8 @@ write_c_file (stream, name) ...@@ -1297,8 +1307,8 @@ write_c_file (stream, name)
write_list (stream, "\t", destructors.first); write_list (stream, "\t", destructors.first);
fprintf (stream, "\t0\n};\n\n"); fprintf (stream, "\t0\n};\n\n");
fprintf (stream, "extern entry_pt __main;\n"); fprintf (stream, "extern entry_pt %s;\n", NAME__MAIN);
fprintf (stream, "entry_pt *__main_reference = __main;\n\n"); fprintf (stream, "entry_pt *__main_reference = %s;\n\n", NAME__MAIN);
} }
...@@ -1790,11 +1800,13 @@ scan_prog_file (prog_name, which_pass) ...@@ -1790,11 +1800,13 @@ scan_prog_file (prog_name, which_pass)
if (rw) if (rw)
{ {
char *n = name; char *n = name + strlen (name) - strlen (NAME__MAIN);
while (*n == '_')
++n; if ((n - name) < 0 || strcmp (n, NAME__MAIN))
if (*n != 'm' || (n - name) < 2 || strcmp (n, "main"))
continue; continue;
while (n != name)
if (*--n != '_')
continue;
main_sym = sym; main_sym = sym;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment