-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lines for MASM symbols #68
Conversation
Have a look on this file: https://github.com/mozilla/dump_syms/blob/master/test_data/basic-opt32.pdb, in particular for proc symbols located in d:\agent_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm. [calixte@rouxpanda] ~/dev/mozilla/pdb$ cargo run --release --example pdb_lines ../dump_syms.calixteman/test_data/basic-opt32.pdb | rg '_local_unwind4|_unwind_handler4|_seh_longjmp_unwind4|_EH4_CallFilterFunc|_EH4_TransferToHandler| _EH4_GlobalUnwind2|_EH4_LocalUnwind' -A1
Finished release [optimized] target(s) in 0.05s
Running `target/release/examples/pdb_lines ../dump_syms.calixteman/test_data/basic-opt32.pdb`
+ @_EH4_CallFilterFunc@8
0xaeb0 d:\agent\_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm:159::Some(0)
--
+ _local_unwind4
0xaeb0 d:\agent\_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm:159::Some(0)
--
+ _seh_longjmp_unwind4
0xaeb0 d:\agent\_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm:159::Some(0)
--
- _unwind_handler4
0xaeb0 d:\agent\_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm:159::Some(0)
--
+ @_EH4_LocalUnwind@16
0xaeb0 d:\agent\_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm:159::Some(0)
--
+ @_EH4_TransferToHandler@8
0xaeb0 d:\agent\_work\3\s\src\vctools\crt\vcruntime\src\eh\i386\exsup4.asm:159::Some(0) The lines for each symbol start at 0xaeb0 which is wrong. |
FYI, all the function findLines** from DIA sdk have a length argument: |
That's a good point. I was sort of assuming that the user of Alright, let's update the tests to use the above functions and then see if we can get correct behavior. For reference, do you have the expected lines for the functions you pasted above? Also, what if the given offset points into the middle of a line record? Do you expect the line record to be included or not? (i.e. is the first line covering the given offset or at or after the given offset)? |
Yep the output for security_check_cookie is correct. |
impl fmt::Debug for C13LineIterator<'_> { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.debug_struct("LineIterator") | ||
.field("sections", &self.sections.as_slice()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This is still work in progress, unfortunately. I will have to rebase this on latest
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @calixteman did point to a potential problem that should still be investigated. Is it possible to fuzz this somehow?
All issues mentioned in this PR have been fixed, and we have tests for these cases now. Pending a final verification with @loewenheim, I'm going to merge this. |
ProcedureSymbol
records for MASM functions have code ranges associated that do not match the actual code or line records.lines_at_offset
assumed that if there is a lines subsection for a symbol, it shares the exact same start offset as the symbol. However, this is not the case for MASM functions, where the symbol's offset can lie after the actual start of the instructions / line records. Since the name oflines_at_offset
was chosen badly, it is now renamed tolines_for_symbol
, and explicitly states that it may return line records outside of the symbol's stated code range.A consumer of this should probably collect the line records for each symbol and infer a proper code range.
Also, the internal implementation of
lines_at_offset
was slow in two regards: It had linear runtime complexity, and repeatedly had to iterate through large chunks of memory to find the appropriate section.LineProgram
now collects and sorts all line sections ahead of time to perform faster binary search.Fixes #61
Fixes #63