* [Ada] Fix end-of dwarf section detection in address symbolizer
@ 2017-12-05 12:12 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2017-12-05 12:12 UTC (permalink / raw)
To: gcc-patches; +Cc: Olivier Hainque
[-- Attachment #1: Type: text/plain, Size: 812 bytes --]
When executing a Line Number program statement, the state machine bails
out a few bytes before the current offset reaches the end of section to
account for possible padding bytes at the end.
The current test is checking if current_offset + 4 >= section_length,
which is too early for e.g. a program terminating with
Advance PC by constant 17 to 0x776
Extended opcode 1: End of Sequence
at offset 101 for a section with length 105.
This change tightens the computation, allowing proper interpretation
in the example case above, and explains the rationale.
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-12-05 Olivier Hainque <hainque@adacore.com>
* s-dwalin.adb (Read_And_Execute_Isn): Adjust test checking for the end
of section. Add comments explaining the rationale of the computation.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1445 bytes --]
Index: libgnat/s-dwalin.adb
===================================================================
--- libgnat/s-dwalin.adb (revision 255411)
+++ libgnat/s-dwalin.adb (working copy)
@@ -578,14 +578,21 @@
Initialize_State_Machine (C);
end if;
- -- Read the next prologue
+ -- If we have reached the next prologue, read it. Beware of possibly
+ -- empty blocks.
+ -- When testing for the end of section, beware of possible zero padding
+ -- at the end. Bail out as soon as there's not even room for at least a
+ -- DW_LNE_end_sequence, 3 bytes from Off to Off+2. This resolves to
+ -- Off+2 > Last_Offset_Within_Section, that is Off+2 > Section_Length-1,
+ -- or Off+3 > Section_Length.
+
Tell (C.Lines, Off);
while Off = C.Next_Prologue loop
Initialize_State_Machine (C);
Parse_Prologue (C);
Tell (C.Lines, Off);
- exit when Off + 4 >= Length (C.Lines);
+ exit when Off + 3 > Length (C.Lines);
end loop;
-- Test whether we're done
@@ -595,7 +602,7 @@
-- We are finished when we either reach the end of the section, or we
-- have reached zero padding at the end of the section.
- if Prologue.Unit_Length = 0 or else Off + 4 >= Length (C.Lines) then
+ if Prologue.Unit_Length = 0 or else Off + 3 > Length (C.Lines) then
Done := True;
return;
end if;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-05 12:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 12:12 [Ada] Fix end-of dwarf section detection in address symbolizer Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).