diff options
Diffstat (limited to 'gcc/ada/mdll.adb')
-rw-r--r-- | gcc/ada/mdll.adb | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/gcc/ada/mdll.adb b/gcc/ada/mdll.adb index b542eeef2a9..37dc55fff1e 100644 --- a/gcc/ada/mdll.adb +++ b/gcc/ada/mdll.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -29,6 +29,7 @@ with Ada.Text_IO; +with GNAT.Directory_Operations; with MDLL.Utl; with MDLL.Fil; @@ -70,6 +71,10 @@ package body MDLL is Out_Opt : aliased String := "-o"; Adr_Opt : aliased String := "-Wl,--image-base=" & Lib_Address; + L_Afiles : Argument_List := Afiles; + -- Local afiles list. This list can be reordered to ensure that the + -- binder ali file is not the first entry in this list. + All_Options : constant Argument_List := Options & Largs_Options; procedure Build_Reloc_DLL; @@ -179,7 +184,7 @@ package body MDLL is -- 1) Build base file with objects files. - Utl.Gnatbind (Afiles, Options & Bargs_Options); + Utl.Gnatbind (L_Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := @@ -187,7 +192,7 @@ package body MDLL is Lib_Opt'Unchecked_Access & Bas_Opt'Unchecked_Access & Ofiles & All_Options; begin - Utl.Gnatlink (Afiles (Afiles'Last).all, Params); + Utl.Gnatlink (L_Afiles (L_Afiles'Last).all, Params); end; -- 2) Build exp from base file. @@ -199,7 +204,7 @@ package body MDLL is -- 3) Build base file with exp file and objects files. - Utl.Gnatbind (Afiles, Options & Bargs_Options); + Utl.Gnatbind (L_Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := @@ -210,7 +215,7 @@ package body MDLL is Ofiles & All_Options; begin - Utl.Gnatlink (Afiles (Afiles'Last).all, Params); + Utl.Gnatlink (L_Afiles (L_Afiles'Last).all, Params); end; -- 4) Build new exp from base file and the lib file (.a) @@ -222,7 +227,7 @@ package body MDLL is -- 5) Build the dynamic library - Utl.Gnatbind (Afiles, Options & Bargs_Options); + Utl.Gnatbind (L_Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := @@ -233,7 +238,7 @@ package body MDLL is Ofiles & All_Options; begin - Utl.Gnatlink (Afiles (Afiles'Last).all, Params); + Utl.Gnatlink (L_Afiles (L_Afiles'Last).all, Params); end; OS_Lib.Delete_File (Exp_File, Success); @@ -317,7 +322,7 @@ package body MDLL is -- Build the DLL - Utl.Gnatbind (Afiles, Options & Bargs_Options); + Utl.Gnatbind (L_Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := @@ -328,7 +333,7 @@ package body MDLL is Ofiles & All_Options; begin - Utl.Gnatlink (Afiles (Afiles'Last).all, Params); + Utl.Gnatlink (L_Afiles (L_Afiles'Last).all, Params); end; OS_Lib.Delete_File (Exp_File, Success); @@ -340,17 +345,35 @@ package body MDLL is end Ada_Build_Non_Reloc_DLL; begin + -- On Windows the binder file must not be in the first position + -- in the list. This is due to the way DLL's are built on Windows. + -- We swap the first ali with the last one if it is the case. + + if L_Afiles'Length > 1 then + declare + Filename : constant String := + Directory_Operations.Base_Name (L_Afiles (1).all); + First : constant Positive := Filename'First; + + begin + if Filename (First .. First + 1) = "b~" then + L_Afiles (L_Afiles'Last) := Afiles (1); + L_Afiles (1) := Afiles (Afiles'Last); + end if; + end; + end if; + case Relocatable is when True => - if Afiles'Length = 0 then + if L_Afiles'Length = 0 then Build_Reloc_DLL; else Ada_Build_Reloc_DLL; end if; when False => - if Afiles'Length = 0 then + if L_Afiles'Length = 0 then Build_Non_Reloc_DLL; else Ada_Build_Non_Reloc_DLL; |