[COMMITTED,12/14] ada: Fix relocatable DLL creation with gnatdll

Message ID 20250113105349.928779-12-poulhies@adacore.com
State Committed
Commit 2e0b086f8403e00da964d44039c667d5b1806070
Headers
Series [COMMITTED,01/14] ada: Fix parsing of raise expressions with no parens |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Marc Poulhiès Jan. 13, 2025, 10:53 a.m. UTC
  From: Pascal Obry <obry@adacore.com>

gcc/ada/ChangeLog:

	* mdll.adb: For the created DLL to be relocatable we do not want to use
	the base file name when calling gnatdll.
	* gnatdll.adb: Removes option -d which is not working anymore. And
	when using a truly relocatable DLL the base-address has no real
	meaning. Also reword the usage string for -d as we do not want to
	specify relocatable as gnatdll can be used to create both
	relocatable and non relocatable DLL.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gnatdll.adb |  8 +-------
 gcc/ada/mdll.adb    | 13 +++++--------
 2 files changed, 6 insertions(+), 15 deletions(-)
  

Patch

diff --git a/gcc/ada/gnatdll.adb b/gcc/ada/gnatdll.adb
index 8881fc91ab4..0faf79f361b 100644
--- a/gcc/ada/gnatdll.adb
+++ b/gcc/ada/gnatdll.adb
@@ -134,10 +134,8 @@  procedure Gnatdll is
       P ("   -l file       File contains a list-of-files to be added to "
          & "the library");
       P ("   -e file       Definition file containing exports");
-      P ("   -d file       Put objects in the relocatable dynamic "
+      P ("   -d file       Put objects in the dynamic "
          & "library <file>");
-      P ("   -b addr       Set base address for the relocatable DLL");
-      P ("                 default address is " & Default_DLL_Address);
       P ("   -a[addr]      Build non-relocatable DLL at address <addr>");
       P ("                 if <addr> is not specified use "
          & Default_DLL_Address);
@@ -315,10 +313,6 @@  procedure Gnatdll is
 
                Must_Build_Relocatable := False;
 
-            when 'b' =>
-               DLL_Address := To_Unbounded_String (Parameter);
-               Must_Build_Relocatable := True;
-
             when 'e' =>
                Def_Filename := To_Unbounded_String (Parameter);
 
diff --git a/gcc/ada/mdll.adb b/gcc/ada/mdll.adb
index 281f6a97e5f..64350ff2ec3 100644
--- a/gcc/ada/mdll.adb
+++ b/gcc/ada/mdll.adb
@@ -77,10 +77,7 @@  package body MDLL is
       Bas_Opt  : aliased String := "-Wl,--base-file," & Bas_File;
       Lib_Opt  : aliased String := "-mdll";
       Out_Opt  : aliased String := "-o";
-      Adr_Opt  : aliased String :=
-                   (if Relocatable
-                    then ""
-                    else "-Wl,--image-base=" & Lib_Address);
+      Adr_Opt  : aliased String := "-Wl,--image-base=" & Lib_Address;
       Map_Opt  : aliased String := "-Wl,-Map," & Lib_Filename & ".map";
 
       L_Afiles : Argument_List := Afiles;
@@ -133,7 +130,7 @@  package body MDLL is
          --  2) Build exp from base file
 
          Utl.Dlltool (Def_File, Dll_File, Lib_File,
-                      Base_File    => Bas_File,
+                      Base_File    => (if Relocatable then "" else Bas_File),
                       Exp_Table    => Exp_File,
                       Build_Import => False);
 
@@ -148,7 +145,7 @@  package body MDLL is
          --  4) Build new exp from base file and the lib file (.a)
 
          Utl.Dlltool (Def_File, Dll_File, Lib_File,
-                      Base_File    => Bas_File,
+                      Base_File    => (if Relocatable then "" else Bas_File),
                       Exp_Table    => Exp_File,
                       Build_Import => Build_Import);
 
@@ -223,7 +220,7 @@  package body MDLL is
          --  2) Build exp from base file
 
          Utl.Dlltool (Def_File, Dll_File, Lib_File,
-                      Base_File    => Bas_File,
+                      Base_File    => (if Relocatable then "" else Bas_File),
                       Exp_Table    => Exp_File,
                       Build_Import => False);
 
@@ -247,7 +244,7 @@  package body MDLL is
          --  4) Build new exp from base file and the lib file (.a)
 
          Utl.Dlltool (Def_File, Dll_File, Lib_File,
-                      Base_File    => Bas_File,
+                      Base_File    => (if Relocatable then "" else Bas_File),
                       Exp_Table    => Exp_File,
                       Build_Import => Build_Import);