diff options
author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-05-18 18:34:51 +0000 |
---|---|---|
committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-05-18 18:34:51 +0000 |
commit | d210f3fff74356d78e758863a76d961f69971b4e (patch) | |
tree | 317916a4b2bad48f4f182a4e224dbad018ff6510 /gcc/java/jvspec.c | |
parent | 943bf3c71fc70451d125c77a8d65af8d93ca1428 (diff) | |
download | gcc-d210f3fff74356d78e758863a76d961f69971b4e.tar.gz |
* jvspec.c (lang_specific_pre_link): Re-arrange the linker
command line so the jvgenmain-generated main program comes first.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42270 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/jvspec.c')
-rw-r--r-- | gcc/java/jvspec.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index c02071ff308..4a8c333db34 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -525,9 +525,23 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) int lang_specific_pre_link () { + int err; if (main_class_name == NULL) return 0; input_filename = main_class_name; input_filename_length = strlen (main_class_name); - return do_spec (jvgenmain_spec); + err = do_spec (jvgenmain_spec); + if (err == 0) + { + /* Shift the outfiles array so the generated main comes first. + This is important when linking against (non-shared) libraries, + since otherwise we risk (a) nothing getting linked or + (b) 'main' getting picked up from a library. */ + int i = n_infiles; + const char *generated = outfiles[i]; + while (--i >= 0) + outfiles[i + 1] = outfiles[i]; + outfiles[0] = generated; + } + return err; } |