diff mbox

[Ada] No adainit/adafinal procedures in Stand-Alone Libraries

Message ID 20110801090505.GA29356@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 1, 2011, 9:05 a.m. UTC
This patch set the names of the init and final procedures of
Stand-Alone Libraries to "ada_init" and "ada_final" if the name of the
library is "ada", to avoid duplicate symbols "adainit" and "adafinal" in
executables.
The test for this is to build an executable using a shared SAL with the
name "ada". It should behave as if the name of the SAL was different from
"ada".

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-01  Vincent Celier  <celier@adacore.com>

	* mlib-prj.adb (Build_Library): Use "ada_" as the prefix for the "init"
	and "final" procedures when the name of the library is "ada", to avoid
	duplicate symbols "adainit" and "adafinal" in executables.
diff mbox

Patch

Index: mlib-prj.adb
===================================================================
--- mlib-prj.adb	(revision 176998)
+++ mlib-prj.adb	(working copy)
@@ -862,7 +862,7 @@  package body MLib.Prj is
                Arguments := new String_List (1 .. Initial_Argument_Max);
             end if;
 
-            --  Add "-n -o b~<lib>.adb (b__<lib>.adb on VMS) -L<lib>"
+            --  Add "-n -o b~<lib>.adb (b__<lib>.adb on VMS) -L<lib>_"
 
             Argument_Number := 2;
             Arguments (1) := No_Main;
@@ -875,7 +875,17 @@  package body MLib.Prj is
             Add_Argument
               (B_Start.all
                & Get_Name_String (For_Project.Library_Name) & ".adb");
-            Add_Argument ("-L" & Get_Name_String (For_Project.Library_Name));
+
+            --  Make sure that the init procedure is never "adainit"
+
+            Get_Name_String (For_Project.Library_Name);
+
+            if Name_Buffer (1 .. Name_Len) = "ada" then
+               Add_Argument ("-Lada_");
+            else
+               Add_Argument
+                 ("-L" & Get_Name_String (For_Project.Library_Name));
+            end if;
 
             if For_Project.Lib_Auto_Init and then SALs_Use_Constructors then
                Add_Argument (Auto_Initialize);
@@ -950,16 +960,15 @@  package body MLib.Prj is
                then
                   if Check_Project (Unit.File_Names (Impl).Project) then
                      if Unit.File_Names (Spec) = null then
-                        declare
-                           Src_Ind : Source_File_Index;
-
-                        begin
-                           Src_Ind := Sinput.P.Load_Project_File
-                                        (Get_Name_String
-                                          (Unit.File_Names (Impl).Path.Name));
 
-                           --  Add the ALI file only if it is not a subunit
+                        --  Add the ALI file only if it is not a subunit
 
+                        declare
+                           Src_Ind : constant Source_File_Index :=
+                                       Sinput.P.Load_Project_File
+                                         (Get_Name_String
+                                           (Unit.File_Names (Impl).Path.Name));
+                        begin
                            if not
                              Sinput.P.Source_File_Is_Subunit (Src_Ind)
                            then