aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVincent Celier <celier@adacore.com>2005-07-04 15:26:18 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2005-07-04 15:26:18 +0200
commitb87520cd051656e14f59112793d66c259ffd4f52 (patch)
treed05fc3ff905800886f21e31cfce3310be6ebf1a9 /gcc
parent0556b702920f8de9acfdff66e27c2e0155c41365 (diff)
downloadgcc-b87520cd051656e14f59112793d66c259ffd4f52.zip
gcc-b87520cd051656e14f59112793d66c259ffd4f52.tar.gz
gcc-b87520cd051656e14f59112793d66c259ffd4f52.tar.bz2
mlib-tgt-tru64.adb, [...] (Build_Dynamic_Library): Remove all auto-initialization code...
2005-07-04 Vincent Celier <celier@adacore.com> * mlib-tgt-tru64.adb, mlib-tgt-aix.adb, mlib-tgt-irix.adb, mlib-tgt-hpux.adb, mlib-tgt-linux.adb, mlib-tgt-solaris.adb, mlib-tgt-mingw.adb, mlib-tgt-darwin.adb (Build_Dynamic_Library): Remove all auto-initialization code, as this is now done through the constructor mechanism. * adaint.h, adaint.c (__gnat_binder_supports_auto_init, __gnat_sals_init_using_constructors): New functions. * bindgen.adb (Gen_Output_File_Ada): Generate pragmas Linker_Constructor and Linker_Destructor when switch -a is used. * bindusg.adb: Add line for new switch -a * gnatbind.adb (Gnatbind_Supports_Auto_Init): New Boolean function (Gnatbind): When switch -a is used, check if it is allowed * switch-b.adb (Scan_Binder_Switches): Process new switch -a From-SVN: r101573
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/adaint.c31
-rw-r--r--gcc/ada/adaint.h5
-rw-r--r--gcc/ada/bindgen.adb8
-rw-r--r--gcc/ada/bindusg.adb5
-rw-r--r--gcc/ada/gnatbind.adb29
-rw-r--r--gcc/ada/mlib-tgt-aix.adb22
-rw-r--r--gcc/ada/mlib-tgt-darwin.adb27
-rw-r--r--gcc/ada/mlib-tgt-hpux.adb31
-rw-r--r--gcc/ada/mlib-tgt-irix.adb33
-rw-r--r--gcc/ada/mlib-tgt-linux.adb33
-rw-r--r--gcc/ada/mlib-tgt-mingw.adb155
-rw-r--r--gcc/ada/mlib-tgt-solaris.adb31
-rw-r--r--gcc/ada/mlib-tgt-tru64.adb40
-rw-r--r--gcc/ada/switch-b.adb7
14 files changed, 120 insertions, 337 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 1632b3d..e1453f7 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -2028,6 +2028,7 @@ __gnat_locate_regular_file (char *file_name, char *path_val)
char *
__gnat_locate_exec (char *exec_name, char *path_val)
{
+ char *ptr;
if (!strstr (exec_name, HOST_EXECUTABLE_SUFFIX))
{
char *full_exec_name
@@ -2035,7 +2036,11 @@ __gnat_locate_exec (char *exec_name, char *path_val)
strcpy (full_exec_name, exec_name);
strcat (full_exec_name, HOST_EXECUTABLE_SUFFIX);
- return __gnat_locate_regular_file (full_exec_name, path_val);
+ ptr = __gnat_locate_regular_file (full_exec_name, path_val);
+
+ if (ptr == 0)
+ return __gnat_locate_regular_file (exec_name, path_val);
+ return ptr;
}
else
return __gnat_locate_regular_file (exec_name, path_val);
@@ -2668,3 +2673,27 @@ __gnat_set_close_on_exec (int fd ATTRIBUTE_UNUSED,
as by default handles are *not* inherited. */
#endif
}
+
+/* Indicates if platforms supports automatic initialization through the
+ constructor mechanism */
+int
+__gnat_binder_supports_auto_init ()
+{
+#ifdef VMS
+ return 0;
+#else
+ return 1;
+#endif
+}
+
+/* Indicates that Stand-Alone Libraries are automatically initialized through
+ the constructor mechanism */
+int
+__gnat_sals_init_using_constructors ()
+{
+#if defined (__vxworks) || defined (__Lynx__) || defined (VMS)
+ return 0;
+#else
+ return 1;
+#endif
+}
diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h
index ee830e9..af83407 100644
--- a/gcc/ada/adaint.h
+++ b/gcc/ada/adaint.h
@@ -167,4 +167,7 @@ extern int get_gcc_version (void);
/* This function offers a hook for libgnarl to set the
locking subprograms for libgcc_eh. */
extern void __gnatlib_install_locks (void (*) (void),
- void (*) (void));
+ void (*) (void));
+
+extern int __gnat_binder_supports_auto_init (void);
+extern int __gnat_sals_init_using_constructors (void);
diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index d692899..e37a386 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -2351,11 +2351,19 @@ package body Bindgen is
WBI (" pragma Export (C, " & Ada_Final_Name.all & ", """ &
Ada_Final_Name.all & """);");
+ if Use_Pragma_Linker_Constructor then
+ WBI (" pragma Linker_Destructor (" & Ada_Final_Name.all & ");");
+ end if;
+
WBI ("");
WBI (" procedure " & Ada_Init_Name.all & ";");
WBI (" pragma Export (C, " & Ada_Init_Name.all & ", """ &
Ada_Init_Name.all & """);");
+ if Use_Pragma_Linker_Constructor then
+ WBI (" pragma Linker_Constructor (" & Ada_Init_Name.all & ");");
+ end if;
+
if Bind_Main_Program then
-- If we have the standard library, then Break_Start is defined
diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb
index 5a232e6..60deb26 100644
--- a/gcc/ada/bindusg.adb
+++ b/gcc/ada/bindusg.adb
@@ -51,6 +51,11 @@ begin
Write_Str (" -aIdir Specify source files search path");
Write_Eol;
+ -- Line for a switch
+
+ Write_Str (" -a Automatically initialize elaboration procedure");
+ Write_Eol;
+
-- Line for A switch
Write_Str (" -A Generate binder program in Ada (default)");
diff --git a/gcc/ada/gnatbind.adb b/gcc/ada/gnatbind.adb
index 4ed9685..cbd3cea 100644
--- a/gcc/ada/gnatbind.adb
+++ b/gcc/ada/gnatbind.adb
@@ -75,6 +75,10 @@ procedure Gnatbind is
Mapping_File : String_Ptr := null;
+ function Gnatbind_Supports_Auto_Init return Boolean;
+ -- Indicates if automatic initialization of elaboration procedure
+ -- through the constructor mechanism is possible on the platform.
+
procedure List_Applicable_Restrictions;
-- List restrictions that apply to this partition if option taken
@@ -83,6 +87,18 @@ procedure Gnatbind is
-- All the one character arguments are still handled by Switch. This
-- routine handles -aO -aI and -I-.
+ ---------------------------------
+ -- Gnatbind_Supports_Auto_Init --
+ ---------------------------------
+
+ function Gnatbind_Supports_Auto_Init return Boolean is
+ function gnat_binder_supports_auto_init return Integer;
+ pragma Import (C, gnat_binder_supports_auto_init,
+ "__gnat_binder_supports_auto_init");
+ begin
+ return gnat_binder_supports_auto_init /= 0;
+ end Gnatbind_Supports_Auto_Init;
+
----------------------------------
-- List_Applicable_Restrictions --
----------------------------------
@@ -393,6 +409,19 @@ begin
Next_Arg := Next_Arg + 1;
end loop Scan_Args;
+ if Use_Pragma_Linker_Constructor then
+ if Bind_Main_Program then
+ Fail ("switch -a must be used in conjunction with -n or -Lxxx");
+
+ elsif not Ada_Bind_File then
+ Fail ("switch -a cannot be used when C code is generated");
+
+ elsif not Gnatbind_Supports_Auto_Init then
+ Fail ("automatic initialisation of elaboration " &
+ "not supported on this platform");
+ end if;
+ end if;
+
-- Test for trailing -o switch
if Opt.Output_File_Name_Present
diff --git a/gcc/ada/mlib-tgt-aix.adb b/gcc/ada/mlib-tgt-aix.adb
index d5faf17..80b3a4b 100644
--- a/gcc/ada/mlib-tgt-aix.adb
+++ b/gcc/ada/mlib-tgt-aix.adb
@@ -47,12 +47,6 @@ package body MLib.Tgt is
No_Arguments : aliased Argument_List := (1 .. 0 => null);
Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
- Wl_Initfini_String : constant String := "-Wl,-binitfini:";
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => null);
- -- Used to put switch for automatic elaboration/finalization
-
Bexpall : aliased String := "-Wl,-bexpall";
Bexpall_Option : constant String_Access := Bexpall'Access;
-- The switch to export all symbols
@@ -142,16 +136,13 @@ package body MLib.Tgt is
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
pragma Unreferenced (Lib_Version);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
MLib.Fil.Ext_To (Lib_Filename, DLL_Ext);
-- The file name of the library
- Init_Fini : Argument_List_Access := Empty_Argument_List;
- -- The switch for automatic initialization of Stand-Alone Libraries.
- -- Changed to a real switch when Auto_Init is True.
-
Thread_Opts : Argument_List_Access := Empty_Argument_List;
-- Set to Thread_Options if -lgnarl is found in the Options
@@ -161,15 +152,6 @@ package body MLib.Tgt is
Write_Line (Lib_File);
end if;
- -- If specified, add automatic elaboration/finalization
-
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (1) :=
- new String'(Wl_Initfini_String & Lib_Filename & "init:" &
- Lib_Filename & "final");
- end if;
-
-- Look for -lgnarl in Options. If found, set the thread options.
for J in Options'Range loop
@@ -223,7 +205,7 @@ package body MLib.Tgt is
MLib.Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options => Options & Bexpall_Option & Init_Fini.all,
+ Options => Options & Bexpall_Option,
Driver_Name => Driver_Name,
Options_2 => Options_2 & Thread_Opts.all);
end Build_Dynamic_Library;
diff --git a/gcc/ada/mlib-tgt-darwin.adb b/gcc/ada/mlib-tgt-darwin.adb
index c0decf0..a152ed3 100644
--- a/gcc/ada/mlib-tgt-darwin.adb
+++ b/gcc/ada/mlib-tgt-darwin.adb
@@ -43,19 +43,6 @@ package body MLib.Tgt is
use GNAT;
use MLib;
- No_Arguments : aliased Argument_List := (1 .. 0 => null);
- Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
-
- Wl_Init_String : aliased String := "-Wl,-init";
- Wl_Init : constant String_Access := Wl_Init_String'Access;
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => Wl_Init,
- 2 => null);
- -- Used to put switches for automatic elaboration. Note that there is no
- -- linking option on Darwin for automatic finalization of a shared
- -- library.
-
---------------------
-- Archive_Builder --
---------------------
@@ -123,6 +110,7 @@ package body MLib.Tgt is
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
@@ -131,8 +119,6 @@ package body MLib.Tgt is
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
- Init_Fini : Argument_List_Access := Empty_Argument_List;
-
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
@@ -141,16 +127,11 @@ package body MLib.Tgt is
-- If specified, add automatic elaboration/finalization
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (2) := new String'("-Wl,_" & Lib_Filename & "init");
- end if;
-
if Lib_Version = "" then
Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options => Options & Init_Fini.all,
+ Options => Options,
Driver_Name => Driver_Name,
Options_2 => Options_2);
@@ -165,7 +146,7 @@ package body MLib.Tgt is
Utl.Gcc
(Output_File => Lib_Version,
Objects => Ofiles,
- Options => Options & Version_Arg & Init_Fini.all,
+ Options => Options & Version_Arg,
Driver_Name => Driver_Name,
Options_2 => Options_2);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@@ -174,7 +155,7 @@ package body MLib.Tgt is
Utl.Gcc
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
- Options => Options & Version_Arg & Init_Fini.all,
+ Options => Options & Version_Arg,
Driver_Name => Driver_Name,
Options_2 => Options_2);
Symbolic_Link_Needed :=
diff --git a/gcc/ada/mlib-tgt-hpux.adb b/gcc/ada/mlib-tgt-hpux.adb
index d11dd5e..62172c7 100644
--- a/gcc/ada/mlib-tgt-hpux.adb
+++ b/gcc/ada/mlib-tgt-hpux.adb
@@ -40,20 +40,6 @@ with System;
package body MLib.Tgt is
- No_Arguments : aliased Argument_List := (1 .. 0 => null);
- Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
-
- Wl_Init_String : aliased String := "-Wl,+init";
- Wl_Init : constant String_Access := Wl_Init_String'Access;
- Wl_Fini_String : aliased String := "-Wl,+fini";
- Wl_Fini : constant String_Access := Wl_Fini_String'Access;
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => Wl_Init,
- 2 => null,
- 3 => Wl_Fini,
- 4 => null);
- -- Used to put switches for automatic elaboration/finalization
---------------------
-- Archive_Builder --
---------------------
@@ -121,6 +107,7 @@ package body MLib.Tgt is
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
@@ -129,8 +116,6 @@ package body MLib.Tgt is
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
- Init_Fini : Argument_List_Access := Empty_Argument_List;
-
Common_Options : constant Argument_List :=
Options & new String'(PIC_Option);
-- Common set of options to the gcc command performing the link.
@@ -144,19 +129,11 @@ package body MLib.Tgt is
Write_Line (Lib_File);
end if;
- -- If specified, add automatic elaboration/finalization
-
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (2) := new String'("-Wl," & Lib_Filename & "init");
- Init_Fini (4) := new String'("-Wl," & Lib_Filename & "final");
- end if;
-
if Lib_Version = "" then
MLib.Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options => Common_Options & Init_Fini.all,
+ Options => Common_Options,
Options_2 => Options_2,
Driver_Name => Driver_Name);
@@ -167,7 +144,7 @@ package body MLib.Tgt is
MLib.Utl.Gcc
(Output_File => Lib_Version,
Objects => Ofiles,
- Options => Common_Options & Version_Arg & Init_Fini.all,
+ Options => Common_Options & Version_Arg,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@@ -176,7 +153,7 @@ package body MLib.Tgt is
MLib.Utl.Gcc
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
- Options => Common_Options & Version_Arg & Init_Fini.all,
+ Options => Common_Options & Version_Arg,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
diff --git a/gcc/ada/mlib-tgt-irix.adb b/gcc/ada/mlib-tgt-irix.adb
index 3baa39a..7a77bff 100644
--- a/gcc/ada/mlib-tgt-irix.adb
+++ b/gcc/ada/mlib-tgt-irix.adb
@@ -40,21 +40,6 @@ with System;
package body MLib.Tgt is
- No_Arguments : aliased Argument_List := (1 .. 0 => null);
- Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
-
- Wl_Init_String : aliased String := "-Wl,-init";
- Wl_Init : constant String_Access := Wl_Init_String'Access;
- Wl_Fini_String : aliased String := "-Wl,-fini";
- Wl_Fini : constant String_Access := Wl_Fini_String'Access;
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => Wl_Init,
- 2 => null,
- 3 => Wl_Fini,
- 4 => null);
- -- Used to put switches for automatic elaboration/finalization
-
---------------------
-- Archive_Builder --
---------------------
@@ -122,6 +107,7 @@ package body MLib.Tgt is
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
@@ -130,8 +116,6 @@ package body MLib.Tgt is
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
- Init_Fini : Argument_List_Access := Empty_Argument_List;
-
N_Options : Argument_List := Options;
Options_Last : Natural := N_Options'Last;
-- After moving -lxxx to Options_2, N_Options up to index Options_Last
@@ -148,14 +132,6 @@ package body MLib.Tgt is
Write_Line (Lib_File);
end if;
- -- If specified, add automatic elaboration/finalization
-
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (2) := new String'("-Wl," & Lib_Filename & "init");
- Init_Fini (4) := new String'("-Wl," & Lib_Filename & "final");
- end if;
-
-- Move all -lxxx to Options_2
declare
@@ -192,8 +168,7 @@ package body MLib.Tgt is
MLib.Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options => N_Options (N_Options'First .. Options_Last) &
- Init_Fini.all,
+ Options => N_Options (N_Options'First .. Options_Last),
Driver_Name => Driver_Name,
Options_2 => Real_Options_2 (1 .. Real_Options_2_Last));
@@ -205,7 +180,7 @@ package body MLib.Tgt is
(Output_File => Lib_Version,
Objects => Ofiles,
Options => N_Options (N_Options'First .. Options_Last) &
- Version_Arg & Init_Fini.all,
+ Version_Arg,
Driver_Name => Driver_Name,
Options_2 => Real_Options_2 (1 .. Real_Options_2_Last));
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@@ -215,7 +190,7 @@ package body MLib.Tgt is
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options => N_Options (N_Options'First .. Options_Last) &
- Version_Arg & Init_Fini.all,
+ Version_Arg,
Driver_Name => Driver_Name,
Options_2 => Real_Options_2 (1 .. Real_Options_2_Last));
Symbolic_Link_Needed :=
diff --git a/gcc/ada/mlib-tgt-linux.adb b/gcc/ada/mlib-tgt-linux.adb
index 2c5e7a1..70fde48 100644
--- a/gcc/ada/mlib-tgt-linux.adb
+++ b/gcc/ada/mlib-tgt-linux.adb
@@ -43,21 +43,6 @@ package body MLib.Tgt is
use GNAT;
use MLib;
- No_Arguments : aliased Argument_List := (1 .. 0 => null);
- Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
-
- Wl_Init_String : aliased String := "-Wl,-init";
- Wl_Init : constant String_Access := Wl_Init_String'Access;
- Wl_Fini_String : aliased String := "-Wl,-fini";
- Wl_Fini : constant String_Access := Wl_Fini_String'Access;
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => Wl_Init,
- 2 => null,
- 3 => Wl_Fini,
- 4 => null);
- -- Used to put switches for automatic elaboration/finalization
-
---------------------
-- Archive_Builder --
---------------------
@@ -125,6 +110,8 @@ package body MLib.Tgt is
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
+ -- Initialization is done through the contructor mechanism
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
@@ -133,27 +120,17 @@ package body MLib.Tgt is
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
- Init_Fini : Argument_List_Access := Empty_Argument_List;
-
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
Write_Line (Lib_File);
end if;
- -- If specified, add automatic elaboration/finalization
-
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (2) := new String'("-Wl," & Lib_Filename & "init");
- Init_Fini (4) := new String'("-Wl," & Lib_Filename & "final");
- end if;
-
if Lib_Version = "" then
Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options => Options & Init_Fini.all,
+ Options => Options,
Driver_Name => Driver_Name,
Options_2 => Options_2);
@@ -164,7 +141,7 @@ package body MLib.Tgt is
Utl.Gcc
(Output_File => Lib_Version,
Objects => Ofiles,
- Options => Options & Version_Arg & Init_Fini.all,
+ Options => Options & Version_Arg,
Driver_Name => Driver_Name,
Options_2 => Options_2);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@@ -173,7 +150,7 @@ package body MLib.Tgt is
Utl.Gcc
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
- Options => Options & Version_Arg & Init_Fini.all,
+ Options => Options & Version_Arg,
Driver_Name => Driver_Name,
Options_2 => Options_2);
Symbolic_Link_Needed :=
diff --git a/gcc/ada/mlib-tgt-mingw.adb b/gcc/ada/mlib-tgt-mingw.adb
index c9fc938..98a5de8 100644
--- a/gcc/ada/mlib-tgt-mingw.adb
+++ b/gcc/ada/mlib-tgt-mingw.adb
@@ -31,8 +31,6 @@
-- This is the Windows version of the body. Works only with GCC versions
-- supporting the "-shared" option.
-with Ada.Characters.Handling; use Ada.Characters.Handling;
-with Ada.Text_IO; use Ada; use Ada.Text_IO;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Namet; use Namet;
@@ -48,6 +46,9 @@ package body MLib.Tgt is
package Files renames MLib.Fil;
package Tools renames MLib.Utl;
+ No_Argument_List : constant String_List := (1 .. 0 => null);
+ -- Used as value of parameter Options or Options2 in calls to Gcc
+
---------------------
-- Archive_Builder --
---------------------
@@ -116,6 +117,7 @@ package body MLib.Tgt is
pragma Unreferenced (Symbol_Data);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Lib_Version);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator &
@@ -129,149 +131,12 @@ package body MLib.Tgt is
Write_Line (Lib_File);
end if;
- -- Generate auto-init routine if in Auto_Init mode
-
- if Auto_Init then
- declare
- Compile_Only : aliased String := "-c";
- GCC : constant String_Access :=
- Locate_Exec_On_Path ("gcc.exe");
- Filename : constant String := To_Lower (Lib_Filename);
- Autoinit_Spec : constant String := Filename & "_autoinit.ads";
- Autoinit_Body : aliased String := Filename & "_autoinit.adb";
- Autoinit_Obj : aliased String := Filename & "_autoinit.o";
- Autoinit_Ali : constant String := Filename & "_autoinit.ali";
- Init_Proc : constant String := Lib_Filename & "init";
- Final_Proc : constant String := Lib_Filename & "final";
- Autoinit_Opt : constant Argument_List :=
- (1 => Autoinit_Obj'Unchecked_Access);
- Arguments : constant Argument_List (1 .. 2) :=
- (Compile_Only'Unchecked_Access,
- Autoinit_Body'Unchecked_Access);
- File : Text_IO.File_Type;
- Success : Boolean;
-
- begin
- if Opt.Verbose_Mode then
- Write_Str ("Creating auto-init Ada file """);
- Write_Str (Autoinit_Spec);
- Write_Str (""" and """);
- Write_Str (Autoinit_Body);
- Write_Line ("""");
- end if;
-
- -- Create the spec
-
- Create (File, Out_File, Autoinit_Spec);
-
- Put_Line (File, "package " & Lib_Filename & "_autoinit is");
- New_Line (File);
- Put_Line (File, " type HINSTANCE is new Integer;");
- Put_Line (File, " type DWORD is new Integer;");
- Put_Line (File, " type LPVOID is new Integer;");
- Put_Line (File, " type BOOL is new Integer;");
- New_Line (File);
- Put_Line (File, " function DllMain");
- Put_Line (File, " (hinstdll : HINSTANCE;");
- Put_Line (File, " fdwreason : DWORD;");
- Put_Line (File, " lpvreserved : LPVOID)");
- Put_Line (File, " return BOOL;");
- Put_Line
- (File, " pragma Export (Stdcall, DllMain, ""DllMain"");");
- New_Line (File);
- Put_Line (File, "end " & Lib_Filename & "_autoinit;");
-
- Close (File);
-
- -- Create the body
-
- Create (File, Out_File, Autoinit_Body);
-
- Put_Line (File, "package body " & Lib_Filename & "_autoinit is");
- New_Line (File);
- Put_Line (File, " DLL_PROCESS_DETACH : constant := 0;");
- Put_Line (File, " DLL_PROCESS_ATTACH : constant := 1;");
- Put_Line (File, " DLL_THREAD_ATTACH : constant := 2;");
- Put_Line (File, " DLL_THREAD_DETACH : constant := 3;");
- New_Line (File);
- Put_Line (File, " procedure " & Init_Proc & ";");
- Put (File, " pragma Import (C, " & Init_Proc);
- Put_Line (File, ", """ & Init_Proc & """);");
- New_Line (File);
- Put_Line (File, " procedure " & Final_Proc & ";");
- Put (File, " pragma Import (C, " & Final_Proc);
- Put_Line (File, ", """ & Final_Proc & """);");
- New_Line (File);
- Put_Line (File, " function DllMain");
- Put_Line (File, " (hinstdll : HINSTANCE;");
- Put_Line (File, " fdwreason : DWORD;");
- Put_Line (File, " lpvreserved : LPVOID)");
- Put_Line (File, " return BOOL");
- Put_Line (File, " is");
- Put_Line (File, " pragma Unreferenced (hinstDLL);");
- Put_Line (File, " pragma Unreferenced (lpvReserved);");
- Put_Line (File, " begin");
- Put_Line (File, " case fdwReason is");
- Put_Line (File, " when DLL_PROCESS_ATTACH =>");
- Put_Line (File, " " & Init_Proc & ";");
- Put_Line (File, " when DLL_PROCESS_DETACH =>");
- Put_Line (File, " " & Final_Proc & ";");
- Put_Line (File, " when DLL_THREAD_ATTACH =>");
- Put_Line (File, " null;");
- Put_Line (File, " when DLL_THREAD_DETACH =>");
- Put_Line (File, " null;");
- Put_Line (File, " when others =>");
- Put_Line (File, " null;");
- Put_Line (File, " end case;");
- Put_Line (File, " return 1;");
- Put_Line (File, " exception");
- Put_Line (File, " when others =>");
- Put_Line (File, " return 0;");
- Put_Line (File, " end DllMain;");
- New_Line (File);
- Put_Line (File, "end " & Lib_Filename & "_autoinit;");
-
- Close (File);
-
- -- Compile the auto-init file
-
- Spawn (GCC.all, Arguments, Success);
-
- if not Success then
- Fail ("unable to compile the auto-init unit for library """,
- Lib_Filename, """");
- end if;
-
- -- Build the SAL library
-
- Tools.Gcc
- (Output_File => Lib_File,
- Objects => Ofiles,
- Options => Tools.No_Argument_List,
- Options_2 => Options & Options_2 & Autoinit_Opt,
- Driver_Name => Driver_Name);
-
- -- Remove generated files
-
- if Opt.Verbose_Mode then
- Write_Str ("deleting auto-init generated files");
- Write_Eol;
- end if;
-
- Delete_File (Autoinit_Spec, Success);
- Delete_File (Autoinit_Body, Success);
- Delete_File (Autoinit_Obj, Success);
- Delete_File (Autoinit_Ali, Success);
- end;
-
- else
- Tools.Gcc
- (Output_File => Lib_File,
- Objects => Ofiles,
- Options => Tools.No_Argument_List,
- Options_2 => Options & Options_2,
- Driver_Name => Driver_Name);
- end if;
+ Tools.Gcc
+ (Output_File => Lib_File,
+ Objects => Ofiles,
+ Options => No_Argument_List,
+ Options_2 => Options & Options_2,
+ Driver_Name => Driver_Name);
end Build_Dynamic_Library;
-------------
diff --git a/gcc/ada/mlib-tgt-solaris.adb b/gcc/ada/mlib-tgt-solaris.adb
index f25347a..40d918e 100644
--- a/gcc/ada/mlib-tgt-solaris.adb
+++ b/gcc/ada/mlib-tgt-solaris.adb
@@ -40,18 +40,6 @@ with System;
package body MLib.Tgt is
- No_Arguments : aliased Argument_List := (1 .. 0 => null);
- Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
-
- Wl_Init_String : constant String := "-Wl,-zinitarray=";
- Wl_Fini_String : constant String := "-Wl,-zfiniarray=";
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => null,
- 2 => null);
-
- -- Used to put switches for automatic elaboration/finalization
-
---------------------
-- Archive_Builder --
---------------------
@@ -119,6 +107,7 @@ package body MLib.Tgt is
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
@@ -127,29 +116,17 @@ package body MLib.Tgt is
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
- Init_Fini : Argument_List_Access := Empty_Argument_List;
-
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
Write_Line (Lib_File);
end if;
- -- If specified, add automatic elaboration/finalization
-
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (1) :=
- new String'(Wl_Init_String & Lib_Filename & "init");
- Init_Fini (2) :=
- new String'(Wl_Fini_String & Lib_Filename & "final");
- end if;
-
if Lib_Version = "" then
Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options => Options & Init_Fini.all,
+ Options => Options,
Options_2 => Options_2,
Driver_Name => Driver_Name);
@@ -160,7 +137,7 @@ package body MLib.Tgt is
Utl.Gcc
(Output_File => Lib_Version,
Objects => Ofiles,
- Options => Options & Version_Arg & Init_Fini.all,
+ Options => Options & Version_Arg,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@@ -169,7 +146,7 @@ package body MLib.Tgt is
Utl.Gcc
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
- Options => Options & Version_Arg & Init_Fini.all,
+ Options => Options & Version_Arg,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
diff --git a/gcc/ada/mlib-tgt-tru64.adb b/gcc/ada/mlib-tgt-tru64.adb
index 267f65d..b6d9549 100644
--- a/gcc/ada/mlib-tgt-tru64.adb
+++ b/gcc/ada/mlib-tgt-tru64.adb
@@ -45,21 +45,6 @@ package body MLib.Tgt is
Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
- No_Arguments : aliased Argument_List := (1 .. 0 => null);
- Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access;
-
- Wl_Init_String : aliased String := "-Wl,-init";
- Wl_Init : constant String_Access := Wl_Init_String'Access;
- Wl_Fini_String : aliased String := "-Wl,-fini";
- Wl_Fini : constant String_Access := Wl_Fini_String'Access;
-
- Init_Fini_List : constant Argument_List_Access :=
- new Argument_List'(1 => Wl_Init,
- 2 => null,
- 3 => Wl_Fini,
- 4 => null);
- -- Used to put switches for automatic elaboration/finalization
-
---------------------
-- Archive_Builder --
---------------------
@@ -127,6 +112,8 @@ package body MLib.Tgt is
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
+ -- Initialization is done through the contructor mechanism
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
@@ -135,8 +122,6 @@ package body MLib.Tgt is
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
- Init_Fini : Argument_List_Access := Empty_Argument_List;
-
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
@@ -145,20 +130,11 @@ package body MLib.Tgt is
-- If specified, add automatic elaboration/finalization
- if Auto_Init then
- Init_Fini := Init_Fini_List;
- Init_Fini (2) := new String'("-Wl," & Lib_Filename & "init");
- Init_Fini (4) := new String'("-Wl," & Lib_Filename & "final");
- end if;
-
if Lib_Version = "" then
Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
- Options =>
- Options &
- Expect_Unresolved'Access &
- Init_Fini.all,
+ Options => Options & Expect_Unresolved'Access,
Options_2 => Options_2,
Driver_Name => Driver_Name);
@@ -170,10 +146,7 @@ package body MLib.Tgt is
(Output_File => Lib_Version,
Objects => Ofiles,
Options =>
- Options &
- Version_Arg &
- Expect_Unresolved'Access &
- Init_Fini.all,
+ Options & Version_Arg & Expect_Unresolved'Access,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
@@ -183,10 +156,7 @@ package body MLib.Tgt is
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options =>
- Options &
- Version_Arg &
- Expect_Unresolved'Access &
- Init_Fini.all,
+ Options & Version_Arg & Expect_Unresolved'Access,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb
index 69a9749..1bc271d 100644
--- a/gcc/ada/switch-b.adb
+++ b/gcc/ada/switch-b.adb
@@ -67,11 +67,16 @@ package body Switch.B is
case C is
+ -- Processing for a switch
+
+ when 'a' =>
+ Ptr := Ptr + 1;
+ Use_Pragma_Linker_Constructor := True;
+
-- Processing for A switch
when 'A' =>
Ptr := Ptr + 1;
-
Ada_Bind_File := True;
-- Processing for b switch