]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Output the load address in backtraces for PIE executables on Darwin
authorSimon Wright <simon@pushface.org>
Wed, 18 Dec 2024 21:26:27 +0000 (22:26 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 18 Dec 2024 21:30:50 +0000 (22:30 +0100)
This aligns Darwin with Linux and Windows.

gcc/ada/
PR target/117538
* libgnat/s-trasym.adb (Symbolic_Traceback): Prepend the load
address of the executable if it is not null.

gcc/ada/libgnat/s-trasym.adb

index 894fcf37ffded7867c97f09ee796d868bc0aaded..e681035cf923bf295f8665fb2f2c3d8ea437d0fb 100644 (file)
@@ -69,7 +69,25 @@ package body System.Traceback.Symbolic is
             end loop;
 
             Result (Last) := ASCII.LF;
-            return Result (1 .. Last);
+
+            declare
+               function Executable_Load_Address return System.Address;
+               pragma Import
+                 (C, Executable_Load_Address,
+                  "__gnat_get_executable_load_address");
+
+               Load_Address : constant System.Address :=
+                 Executable_Load_Address;
+            begin
+               if Load_Address = System.Null_Address then
+                  return Result (1 .. Last);
+               else
+                  return "Load address: 0x"
+                    & System.Address_Image (Load_Address)
+                    & ASCII.LF
+                    & Result (1 .. Last);
+               end if;
+            end;
          end;
       end if;
    end Symbolic_Traceback;