You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-12 23:50:13 +02:00
24 lines
360 B
Go
24 lines
360 B
Go
//+build linux
|
|
|
|
package main
|
|
|
|
import (
|
|
"debug/elf"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func gopclntab() ([]byte, error) {
|
|
file, err := elf.Open(os.Args[0])
|
|
if err != nil {
|
|
return nil, fmt.Errorf("elf.Open: %w", err)
|
|
}
|
|
for _, s := range file.Sections {
|
|
if s.Name == ".gopclntab" {
|
|
return s.Data()
|
|
}
|
|
}
|
|
return nil, errors.New("could not find .gopclntab")
|
|
}
|