]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Adjust again address arithmetics in System.Dwarf_Lines
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 24 Jul 2023 13:02:25 +0000 (15:02 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 3 Aug 2023 12:07:36 +0000 (14:07 +0200)
Using the operator of System.Storage_Elements has introduced a range check
that may be tripped on, so this removes the intermediate conversion to the
Storage_Count subtype that is responsible for it.

gcc/ada/

* libgnat/s-dwalin.adb ("-"): New subtraction operator.
(Enable_Cache): Use it to compute the offset.
(Symbolic_Address): Likewise.

gcc/ada/libgnat/s-dwalin.adb

index d35d03a8a2f86ecae47b58d28c09763ed763f4f2..405b5d32e24b9e6faa06599bf56768584b5e91ad 100644 (file)
@@ -46,6 +46,10 @@ package body System.Dwarf_Lines is
 
    subtype Offset is Object_Reader.Offset;
 
+   function "-" (Left, Right : Address) return uint32;
+   pragma Import (Intrinsic, "-");
+   --  Return the difference between two addresses as an unsigned offset
+
    function Get_Load_Displacement (C : Dwarf_Context) return Storage_Offset;
    --  Return the displacement between the load address present in the binary
    --  and the run-time address at which it is loaded (i.e. non-zero for PIE).
@@ -1542,7 +1546,7 @@ package body System.Dwarf_Lines is
                exit when Ar_Start = Null_Address and Ar_Len = 0;
 
                Len   := uint32 (Ar_Len);
-               Start := uint32 (Storage_Count'(Ar_Start - C.Low));
+               Start := uint32'(Ar_Start - C.Low);
 
                --  Search START in the array
 
@@ -1762,7 +1766,7 @@ package body System.Dwarf_Lines is
 
       if C.Cache /= null then
          declare
-            Off : constant uint32 := uint32 (Storage_Count'(Addr - C.Low));
+            Off : constant uint32 := uint32'(Addr - C.Low);
 
             First, Last, Mid : Natural;
          begin