package body System.Dwarf_Lines is
- SSU : constant := System.Storage_Unit;
-
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).
-- Read an entry format array, as specified by 6.2.4.1
procedure Read_Aranges_Entry
- (C : in out Dwarf_Context;
- Start : out Address;
- Len : out Storage_Count);
+ (C : in out Dwarf_Context;
+ Addr_Size : Natural;
+ Start : out Address;
+ Len : out Storage_Count);
-- Read a single .debug_aranges pair
procedure Read_Aranges_Header
(C : in out Dwarf_Context;
Info_Offset : out Offset;
+ Addr_Size : out Natural;
Success : out Boolean);
-- Read .debug_aranges header
Info_Offset : out Offset;
Success : out Boolean)
is
+ Addr_Size : Natural;
begin
Info_Offset := 0;
Seek (C.Aranges, 0);
while Tell (C.Aranges) < Length (C.Aranges) loop
- Read_Aranges_Header (C, Info_Offset, Success);
+ Read_Aranges_Header (C, Info_Offset, Addr_Size, Success);
exit when not Success;
loop
Start : Address;
Len : Storage_Count;
begin
- Read_Aranges_Entry (C, Start, Len);
+ Read_Aranges_Entry (C, Addr_Size, Start, Len);
exit when Start = 0 and Len = 0;
if Addr >= Start
and then Addr < Start + Len
Unit_Type := Read (C.Info);
Addr_Sz := Read (C.Info);
- if Addr_Sz /= (Address'Size / SSU) then
- return;
- end if;
Read_Section_Offset (C.Info, Abbrev_Offset, Is64);
Read_Section_Offset (C.Info, Abbrev_Offset, Is64);
Addr_Sz := Read (C.Info);
- if Addr_Sz /= (Address'Size / SSU) then
- return;
- end if;
else
return;
procedure Read_Aranges_Header
(C : in out Dwarf_Context;
Info_Offset : out Offset;
+ Addr_Size : out Natural;
Success : out Boolean)
is
Unit_Length : Offset;
-- Read address_size (ubyte)
- Sz := Read (C.Aranges);
- if Sz /= (Address'Size / SSU) then
- return;
- end if;
+ Addr_Size := Natural (uint8'(Read (C.Aranges)));
-- Read segment_size (ubyte)
declare
Cur_Off : constant Offset := Tell (C.Aranges);
- Align : constant Offset := 2 * Address'Size / SSU;
+ Align : constant Offset := 2 * Offset (Addr_Size);
Space : constant Offset := Cur_Off mod Align;
begin
if Space /= 0 then
------------------------
procedure Read_Aranges_Entry
- (C : in out Dwarf_Context;
- Start : out Address;
- Len : out Storage_Count)
+ (C : in out Dwarf_Context;
+ Addr_Size : Natural;
+ Start : out Address;
+ Len : out Storage_Count)
is
begin
-- Read table
- if Address'Size = 32 then
+ if Addr_Size = 4 then
declare
S, L : uint32;
begin
Len := Storage_Count (L);
end;
- elsif Address'Size = 64 then
+ elsif Addr_Size = 8 then
declare
S, L : uint64;
begin
declare
Info_Offset : Offset;
Line_Offset : Offset;
+ Addr_Size : Natural;
Success : Boolean;
Ar_Start : Address;
Ar_Len : Storage_Count;
Seek (C.Aranges, 0);
while Tell (C.Aranges) < Length (C.Aranges) loop
- Read_Aranges_Header (C, Info_Offset, Success);
+ Read_Aranges_Header (C, Info_Offset, Addr_Size, Success);
exit when not Success;
Debug_Info_Lookup (C, Info_Offset, Line_Offset, Success);
-- Read table
loop
- Read_Aranges_Entry (C, Ar_Start, Ar_Len);
+ Read_Aranges_Entry (C, Addr_Size, Ar_Start, Ar_Len);
exit when Ar_Start = Null_Address and Ar_Len = 0;
Len := uint32 (Ar_Len);