From: Eric Botcazou <ebotca...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/s-dwalin.adb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ada/libgnat/s-dwalin.adb b/gcc/ada/libgnat/s-dwalin.adb index d35d03a8a2f..405b5d32e24 100644 --- a/gcc/ada/libgnat/s-dwalin.adb +++ b/gcc/ada/libgnat/s-dwalin.adb @@ -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 -- 2.40.0