char *
__gnat_locate_exec (char *exec_name, char *path_val)
{
+ char *ptr;
if (!strstr (exec_name, HOST_EXECUTABLE_SUFFIX))
{
char *full_exec_name
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);
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
+}
/* 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);
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
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)");
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
-- 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 --
----------------------------------
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
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
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
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
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;
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 --
---------------------
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
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 ");
-- 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);
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;
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 :=
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 --
---------------------
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
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.
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);
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;
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 :=
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 --
---------------------
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
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
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
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));
(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;
(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 :=
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 --
---------------------
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" &
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);
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;
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 :=
-- 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;
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 --
---------------------
pragma Unreferenced (Symbol_Data);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Lib_Version);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator &
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;
-------------
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 --
---------------------
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
+ pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
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);
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;
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 :=
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 --
---------------------
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" &
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 ");
-- 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);
(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;
(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 :=
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