-
Notifications
You must be signed in to change notification settings - Fork 424
Improve elfehframe handling #564
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
Changes from 3 commits
5231549
8fd9cee
4d2e214
d18b5b6
10b60d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,14 +39,15 @@ type extractionFilter struct { | |||||||
|
|
||||||||
| var _ ehframeHooks = &extractionFilter{} | ||||||||
|
|
||||||||
| func (f *extractionFilter) fdeIsUnsorted() { | ||||||||
| f.unsortedFrames = true | ||||||||
| } | ||||||||
|
|
||||||||
| // fdeHook filters out .eh_frame data that is superseded by .gopclntab data | ||||||||
| func (f *extractionFilter) fdeHook(_ *cieInfo, fde *fdeInfo) bool { | ||||||||
| if !fde.sorted { | ||||||||
| // Seems .debug_frame sometimes has broken FDEs for zero address | ||||||||
| if fde.ipStart == 0 { | ||||||||
| return false | ||||||||
| } | ||||||||
| f.unsortedFrames = true | ||||||||
| // Seems .debug_frame sometimes has broken FDEs for zero address | ||||||||
| if f.unsortedFrames && fde.ipStart == 0 { | ||||||||
| return false | ||||||||
| } | ||||||||
| // Parse functions outside the gopclntab area | ||||||||
| if fde.ipStart < f.start || fde.ipStart > f.end { | ||||||||
|
|
@@ -85,8 +86,10 @@ type elfExtractor struct { | |||||||
| allowGenericRegs bool | ||||||||
| } | ||||||||
|
|
||||||||
| func (ee *elfExtractor) extractDebugDeltas() error { | ||||||||
| var err error | ||||||||
| func (ee *elfExtractor) extractDebugDeltas() (err error) { | ||||||||
| if ee.ref == nil { | ||||||||
| return nil | ||||||||
| } | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this check? Looking at the current code I don't see a case where If there is such a case, maybe it makes sense to lift this check higher in the call stack to avoid getting to this point.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a test case that sets elf reference to nil. I'll relocate this test. |
||||||||
|
|
||||||||
| // Attempt finding the associated debug information file with .debug_frame, | ||||||||
| // but ignore errors if it's not available; many production systems | ||||||||
|
|
@@ -122,7 +125,13 @@ func ExtractELF(elfRef *pfelf.Reference, interval *sdtypes.IntervalData) error { | |||||||
| if err != nil { | ||||||||
| return err | ||||||||
| } | ||||||||
| return extractFile(elfFile, elfRef, interval) | ||||||||
| } | ||||||||
|
|
||||||||
| // extractFile extracts the elfFile stack deltas and uses the optional elfRef to resolve | ||||||||
| // debug link references if needed. | ||||||||
| func extractFile(elfFile *pfelf.File, elfRef *pfelf.Reference, | ||||||||
| interval *sdtypes.IntervalData) (err error) { | ||||||||
| // Parse the stack deltas from the ELF | ||||||||
| filter := extractionFilter{} | ||||||||
| deltas := sdtypes.StackDeltaArray{} | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.