Skip to content

Commit

Permalink
Merge pull request opensearch-project#102 from parca-dev/fix_section_…
Browse files Browse the repository at this point in the history
…issue

debuginfo: Ensure unused section removed
  • Loading branch information
kakkoyun authored Oct 18, 2021
2 parents d876941 + 6bfb689 commit de89fb0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/debuginfo/debuginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ func (di *Extractor) useStrip(ctx context.Context, dir string, file string) (*ex
// eu-strip --strip-debug extracts the .debug/.zdebug sections from the object files.
debugInfoFile := path.Join(dir, "debuginfo")
interimFile := path.Join(dir, "binary.stripped")
cmd := exec.CommandContext(ctx, "eu-strip", "--strip-debug", "-f", debugInfoFile, "-o", interimFile, file)
cmd := exec.CommandContext(ctx,
"eu-strip", "--strip-debug",
"--remove-section", ".debug_gdb_scripts", // causes some trouble when it's set to SHT_NOBITS
"-f", debugInfoFile,
"-o", interimFile,
file)
defer func() {
os.Remove(interimFile)
}()
Expand All @@ -301,8 +306,9 @@ func (di *Extractor) useObjcopy(ctx context.Context, dir string, file string) (*
// NOTICE: Keep debug information till we find a better for symbolizing Go binaries without DWARF.
//"-R", ".zdebug_*",
//"-R", ".debug_*",
"-R", ".text", // executable
"-R", ".rodata*", // constants
"--remove-section", ".text", // executable
"--remove-section", ".rodata*", // constants
"--remove-section", ".debug_gdb_scripts", // causes some trouble when it's set to SHT_NOBITS
file, // source
debugInfoFile, // destination
), debugInfoFile
Expand Down

0 comments on commit de89fb0

Please sign in to comment.