diff options
author | Olivier Hainque <hainque@adacore.com> | 2018-05-21 14:50:44 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-21 14:50:44 +0000 |
commit | c77384a44f4e8b30d90c5a1c7f4593cb76c0d67e (patch) | |
tree | 753eba6ee68a4ffae1cc7cb3873caf8d268070b6 /gcc/ada/libgnat | |
parent | 0f090200e7ee7d1ee9d6b84b482618dcba14d92f (diff) | |
download | gcc-c77384a44f4e8b30d90c5a1c7f4593cb76c0d67e.zip gcc-c77384a44f4e8b30d90c5a1c7f4593cb76c0d67e.tar.gz gcc-c77384a44f4e8b30d90c5a1c7f4593cb76c0d67e.tar.bz2 |
[Ada] Tighten Object_Reader.Get_Memory_Bounds
Symbolization of traceback entries from dwarf info was
failing in some cases with shared libraries on ELF targets,
from unexpected overlapping of what we believed were code
regions for distinct modules.
This is caused by the inclusion of all SHF_ALLOC sections in
the set of sections of possible relevance to determine the span
of possible code addresses for a module.
This change renames the Get_memory_Bound subprogram to better
convey that we really care about sections hosting executable code
in particular, matching what the spec comments already claims.
It also renames the boolean flag conveying the info of relevance
in the Object_Section record, and adjusts the ELF implementation
of Get_Section to feed this flag from SHF_EXECINSTR instead of
SHF_ALLOC.
2018-05-21 Olivier Hainque <hainque@adacore.com>
gcc/ada/
* libgnat/s-objrea.ads (Get_Memory_Bounds): Rename as Get_Xcode_Bounds.
(Object_Section): Rename Flag_Alloc component as Flag_Xcode.
* libgnat/s-objrea.adb (Get_Xcode_Bounds): Adjust to new subprogram and
component name.
(Get_Section, ELF case): Set Flag_Xcode from SHF_EXECINSTR.
* libgnat/s-dwalin.adb (Open): Adjust to the Get_Memory_Bounds name
change.
From-SVN: r260451
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r-- | gcc/ada/libgnat/s-dwalin.adb | 5 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-objrea.adb | 17 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-objrea.ads | 6 |
3 files changed, 16 insertions, 12 deletions
diff --git a/gcc/ada/libgnat/s-dwalin.adb b/gcc/ada/libgnat/s-dwalin.adb index a83dae7..b6fa111 100644 --- a/gcc/ada/libgnat/s-dwalin.adb +++ b/gcc/ada/libgnat/s-dwalin.adb @@ -414,9 +414,10 @@ package body System.Dwarf_Lines is Success := True; - -- Get memory bounds + -- Get memory bounds for executable code. Note that such code + -- might come from multiple sections. - Get_Memory_Bounds (C.Obj.all, Lo, Hi); + Get_Xcode_Bounds (C.Obj.all, Lo, Hi); C.Low := Storage_Offset (Lo); C.High := Storage_Offset (Hi); diff --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb index 4c94965..bea13d9 100644 --- a/gcc/ada/libgnat/s-objrea.adb +++ b/gcc/ada/libgnat/s-objrea.adb @@ -114,6 +114,7 @@ package body System.Object_Reader is end record; SHF_ALLOC : constant := 2; + SHF_EXECINSTR : constant := 4; type Symtab_Entry32 is record St_Name : uint32; -- Name (string table index) @@ -552,7 +553,7 @@ package body System.Object_Reader is Offset (SHdr.Sh_Offset), uint64 (SHdr.Sh_Addr), uint64 (SHdr.Sh_Size), - (SHdr.Sh_Flags and SHF_ALLOC) /= 0); + (SHdr.Sh_Flags and SHF_EXECINSTR) /= 0); end Get_Section; ------------------------ @@ -1679,11 +1680,11 @@ package body System.Object_Reader is end if; end Get_Section; - ----------------------- - -- Get_Memory_Bounds -- - ----------------------- + ---------------------- + -- Get_Xcode_Bounds -- + ---------------------- - procedure Get_Memory_Bounds + procedure Get_Xcode_Bounds (Obj : in out Object_File; Low, High : out uint64) is Sec : Object_Section; @@ -1692,9 +1693,11 @@ package body System.Object_Reader is Low := uint64'Last; High := uint64'First; + -- Now find the lowest and highest offsets + -- attached to executable code sections for Idx in 1 .. Num_Sections (Obj) loop Sec := Get_Section (Obj, Idx - 1); - if Sec.Flag_Alloc then + if Sec.Flag_Xcode then if Sec.Addr < Low then Low := Sec.Addr; end if; @@ -1703,7 +1706,7 @@ package body System.Object_Reader is end if; end if; end loop; - end Get_Memory_Bounds; + end Get_Xcode_Bounds; ---------- -- Name -- diff --git a/gcc/ada/libgnat/s-objrea.ads b/gcc/ada/libgnat/s-objrea.ads index d82e21a..1cb08cf 100644 --- a/gcc/ada/libgnat/s-objrea.ads +++ b/gcc/ada/libgnat/s-objrea.ads @@ -277,7 +277,7 @@ package System.Object_Reader is Sec : Object_Section) return Mapped_Stream; -- Create a stream for section Sec - procedure Get_Memory_Bounds + procedure Get_Xcode_Bounds (Obj : in out Object_File; Low, High : out uint64); -- Return the low and high addresses of the code for the object file. Can @@ -434,8 +434,8 @@ private Size : uint64 := 0; -- Length of the section in bytes - Flag_Alloc : Boolean := False; - -- True if the section is mapped in memory by the OS loader + Flag_Xcode : Boolean := False; + -- True if the section is advertised to contain executable code end record; Null_Section : constant Object_Section := (0, 0, 0, 0, False); |