Skip to content

Commit

Permalink
pkg/proc: add inline function support for stripped binaries (#3549)
Browse files Browse the repository at this point in the history
This patch adds support for listing and setting breakpoints on inlined functions within stripped binaries. It uses a forked version of `debug/gosym` copied from golang.org/x/vuln/internal/vulncheck/internal/gosym which adds support for parsing the inline tree of the pclntab section. Parsing this section requires knowing the offset of the "go:func.*" symbol, which is not present in stripped binaries via the ``.symtab` section so instead, we search the `.noptrdata` section which contains `runtime.moduledatap` which contains the value of that missing symbol, which we then can use to find the inline tree for a given function.

Given all this we parse the inline tree for each function we find, and then add that information the the appropriate `Function` contained in `bi.Functions`, using a relatively empty `Function` struct as what would be the abstract origin.
  • Loading branch information
derekparker authored Nov 3, 2023
1 parent 0631684 commit 6c77c35
Show file tree
Hide file tree
Showing 11 changed files with 2,173 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Documentation/backend_test_health.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Tests skipped by each supported backend:
* 2 follow exec not implemented on freebsd
* 4 not implemented
* 1 not working on freebsd
* linux/386/pie skipped = 2
* linux/386 skipped = 1
* 1 not working on linux/386
* linux/386/pie skipped = 1
* 1 broken
* 1 not working on linux/386 with PIE
* linux/ppc64le skipped = 2
* 1 broken - cgo stacktraces
* 1 not working on linux/ppc64le when -gcflags=-N -l is passed
Expand Down
15 changes: 15 additions & 0 deletions _fixtures/inlinestripped.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import "fmt"

func callme(i int) int {
return i * i
}

func main() {
j := 0
j += callme(2)
fmt.Println(j)
fmt.Println(j + 1)
fmt.Println(j + 2)
}
Loading

0 comments on commit 6c77c35

Please sign in to comment.