aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/doc/gnat_ugn
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-11-26 10:11:18 +0100
committerMarc Poulhiès <poulhies@adacore.com>2022-11-28 13:02:32 +0100
commitbe7ea145514eba69a3d53340da3f05f804e48833 (patch)
tree368699c77c633e1f94f3717a3c662984cc8d9822 /gcc/ada/doc/gnat_ugn
parent81885f5cca22fe82adbe90eb1a5f7808fc083bec (diff)
downloadgcc-be7ea145514eba69a3d53340da3f05f804e48833.zip
gcc-be7ea145514eba69a3d53340da3f05f804e48833.tar.gz
gcc-be7ea145514eba69a3d53340da3f05f804e48833.tar.bz2
ada: Adjust runtime library and User's Guide to PIE default on Linux
gcc/ada/ * libgnat/g-traceb.ads: Minor tweaks in the commentary. (Executable_Load_Address): New function. * doc/gnat_ugn/gnat_and_program_execution.rst (Non-Symbolic Traceback): Adjust to PIE default on Linux. (Symbolic Traceback): Likewise. * doc/gnat_ugn/gnat_utility_programs.rst (gnatsymbolize): Likewise. * gnat_ugn.texi: Regenerate.
Diffstat (limited to 'gcc/ada/doc/gnat_ugn')
-rw-r--r--gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst46
-rw-r--r--gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst30
2 files changed, 45 insertions, 31 deletions
diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
index c239c36..45ecea7 100644
--- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
+++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
@@ -859,16 +859,18 @@ bug occurs, and then be able to retrieve the sequence of calls with the same
program compiled with debug information.
However the ``addr2line`` tool does not work with Position-Independent Code
-(PIC), the historical example being Windows DLLs, which nowadays encompasses
-Position-Independent Executables (PIE) on recent Windows versions.
-
-In order to translate addresses into the source lines with Position-Independent
-Executables on recent Windows versions, in other words without using the switch
-:switch:`-no-pie` during linking, you need to use the ``gnatsymbolize`` tool
-with :switch:`--load` instead of the ``addr2line`` tool. The main difference
-is that you need to copy the Load Address output in the traceback ahead of the
-sequence of addresses. And the default mode of ``gnatsymbolize`` is equivalent
-to that of ``addr2line`` with the above switches, so none of them is needed::
+(PIC), the historical example being Linux dynamic libraries and Windows DLLs,
+which nowadays encompasse Position-Independent Executables (PIE) on recent
+Linux and Windows versions.
+
+In order to translate addresses the source lines with Position-Independent
+Executables on recent Linux and Windows versions, in other words without
+using the switch :switch:`-no-pie` during linking, you need to use the
+``gnatsymbolize`` tool with :switch:`--load` instead of the ``addr2line``
+tool. The main difference is that you need to copy the Load Address output
+in the traceback ahead of the sequence of addresses. And the default mode
+of ``gnatsymbolize`` is equivalent to that of ``addr2line`` with the above
+switches, so none of them is needed::
$ gnatmake stb -g -bargs -E
$ stb
@@ -879,7 +881,7 @@ to that of ``addr2line`` with the above switches, so none of them is needed::
Call stack traceback locations:
0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4
- $ gnatsymbolize --load stb 0x400000 0x401373 0x40138b 0x40139c 0x401335
+ $ gnatsymbolize --load stb 0x400000 0x401373 0x40138b 0x40139c 0x401335 \
0x4011c4 0x4011f1 0x77e892a4
0x00401373 Stb.P1 at stb.adb:5
@@ -957,12 +959,17 @@ addresses to strings:
with Ada.Text_IO;
with GNAT.Traceback;
with GNAT.Debug_Utilities;
+ with System;
procedure STB is
use Ada;
+ use Ada.Text_IO;
use GNAT;
use GNAT.Traceback;
+ use System;
+
+ LA : constant Address := Executable_Load_Address;
procedure P1 is
TB : Tracebacks_Array (1 .. 10);
@@ -972,14 +979,14 @@ addresses to strings:
begin
Call_Chain (TB, Len);
- Text_IO.Put ("In STB.P1 : ");
+ Put ("In STB.P1 : ");
for K in 1 .. Len loop
- Text_IO.Put (Debug_Utilities.Image (TB (K)));
- Text_IO.Put (' ');
+ Put (Debug_Utilities.Image_C (TB (K)));
+ Put (' ');
end loop;
- Text_IO.New_Line;
+ New_Line;
end P1;
procedure P2 is
@@ -988,6 +995,10 @@ addresses to strings:
end P2;
begin
+ if LA /= Null_Address then
+ Put_Line ("Load address: " & Debug_Utilities.Image_C (LA));
+ end if;
+
P2;
end STB;
@@ -996,8 +1007,9 @@ addresses to strings:
$ gnatmake stb -g
$ stb
- In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C#
- 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4#
+ Load address: 0x400000
+ In STB.P1 : 0x40F1E4 0x4014F2 0x40170B 0x40171C 0x401461 0x4011C4 \
+ 0x4011F1 0x77E892A4
You can then get further information by invoking the ``addr2line`` tool or
diff --git a/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst b/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst
index 17d3e0d..f2d42e9 100644
--- a/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst
+++ b/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst
@@ -2187,30 +2187,32 @@ building specialized scripts.
This program, when built and run, prints a list of addresses which
correspond to the traceback when inside function ``Call_Me_Third``.
- For instance, on x86_64 GNU/Linux:
+ For instance, on x86-64 GNU/Linux:
::
$ gnatmake -g -q foo.adb
$ ./foo
- 0x0000000000402561
- 0x00000000004025EF
- 0x00000000004025FB
- 0x0000000000402611
- 0x00000000004024C7
+ Load address: 0x00005586C9D7D000
+ 0x00005586C9D81105
+ 0x00005586C9D8119B
+ 0x00005586C9D811A7
+ 0x00005586C9D8128C
+ 0x00005586C9D81069
``gnatsymbolize`` can be used to translate those addresses into
code locations as follow:
::
- $ gnatsymbolize foo 0x0000000000402561 0x00000000004025EF \
- 0x00000000004025FB 0x0000000000402611 0x00000000004024C7
- Pck.Call_Me_Third at pck.adb:12
- Pck.Call_Me_Second at pck.adb:20
- Pck.Call_Me_First at pck.adb:25
- Foo at foo.adb:6
- Main at b~foo.adb:184
+ $ gnatsymbolize --load foo 0x00005586C9D7D000 0x00005586C9D81105 \
+ 0x00005586C9D8119B 0x00005586C9D811A7 0x00005586C9D8128C \
+ 0x00005586C9D81069
+ 0x5586c9d81105 Pck.Call_Me_Third at pck.adb:12
+ 0x5586c9d8119b Pck.Call_Me_Second at pck.adb:20
+ 0x5586c9d811a7 Pck.Call_Me_First at pck.adb:25
+ 0x5586c9d8128c Foo at foo.adb:6
+ 0x5586c9d81069 Main at b~foo.adb:199
Switches for ``gnatsymbolize``
------------------------------
@@ -2243,7 +2245,7 @@ building specialized scripts.
:switch:`--load`
Interpret the first address as the load address of the executable.
- This is needed for position-independent executables on Windows.
+ This is needed for position-independent executables on Linux and Windows.
Requirements for Correct Operation
----------------------------------