From: Olivier Hainque Date: Tue, 22 May 2018 13:20:13 +0000 (+0000) Subject: [Ada] Prevent caching of non-text symbols for symbolic tracebacks X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b8bbe7398f494f96ab33d9c4ee32c83f220d3543;p=gcc.git [Ada] Prevent caching of non-text symbols for symbolic tracebacks We now only have the executable code section boundaries at hand, so can only infer offsets for symbols within those boundaries. Symbols outside of this region are non-text symbols, pointless for traceback symbolization anyway. 2018-05-22 Olivier Hainque gcc/ada/ * libgnat/s-dwalin.adb (Enable_Cache): Skip symbols outside of the executable code section boundaries. From-SVN: r260510 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 06d9bffdacb..6b3e907f5d8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-05-22 Olivier Hainque + + * libgnat/s-dwalin.adb (Enable_Cache): Skip symbols outside of the + executable code section boundaries. + 2018-05-22 Javier Miranda * locales.c: New implementation for the Ada.Locales package. diff --git a/gcc/ada/libgnat/s-dwalin.adb b/gcc/ada/libgnat/s-dwalin.adb index b6fa1111379..0a2d90ededf 100644 --- a/gcc/ada/libgnat/s-dwalin.adb +++ b/gcc/ada/libgnat/s-dwalin.adb @@ -1202,6 +1202,9 @@ package body System.Dwarf_Lines is -- Phase 1: count number of symbols. Phase 2: fill the cache. declare S : Object_Symbol; + Val : uint64; + Xcode_Low : constant uint64 := uint64 (C.Low); + Xcode_High : constant uint64 := uint64 (C.High); Sz : uint32; Addr, Prev_Addr : uint32; Nbr_Symbols : Natural; @@ -1211,22 +1214,31 @@ package body System.Dwarf_Lines is S := First_Symbol (C.Obj.all); Prev_Addr := uint32'Last; while S /= Null_Symbol loop - -- Discard symbols whose length is 0 + -- Discard symbols of length 0 or located outside of the + -- execution code section outer boundaries. Sz := uint32 (Size (S)); + Val := Value (S); - -- Try to filter symbols at the same address. This is a best - -- effort as they might not be consecutive. - Addr := uint32 (Value (S) - uint64 (C.Low)); - if Sz > 0 and then Addr /= Prev_Addr then - Nbr_Symbols := Nbr_Symbols + 1; - Prev_Addr := Addr; - - if Phase = 2 then - C.Cache (Nbr_Symbols) := - (First => Addr, - Size => Sz, - Sym => uint32 (Off (S)), - Line => 0); + if Sz > 0 + and then Val >= Xcode_Low + and then Val <= Xcode_High + then + + Addr := uint32 (Val - Xcode_Low); + + -- Try to filter symbols at the same address. This is a best + -- effort as they might not be consecutive. + if Addr /= Prev_Addr then + Nbr_Symbols := Nbr_Symbols + 1; + Prev_Addr := Addr; + + if Phase = 2 then + C.Cache (Nbr_Symbols) := + (First => Addr, + Size => Sz, + Sym => uint32 (Off (S)), + Line => 0); + end if; end if; end if;