]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/objfile: read file/line information for ELF PIE binaries
authorCherry Mui <cherryyz@google.com>
Fri, 16 Sep 2022 23:41:55 +0000 (19:41 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 22 Sep 2022 23:46:28 +0000 (23:46 +0000)
commitddaf68200a485ae9605a397372b5d59f4dfba759
tree67c050f0743bfae40061dfba29793b312f1a7ccf
parent533cd80315904661e3d644a140bdf52c8ac7aad6
cmd/internal/objfile: read file/line information for ELF PIE binaries

For PIE binaries, the .gopclntab section doesn't have the usual
name, but .data.rel.ro.gopclntab. Try the relro version as well.
If both failed (e.g. for externally linked PIE binaries), try
runtime.pclntab symbol.

This should make cmd/objdump able to print the file/line
information for PIE binaries.

I attempted to do this a few years ago, but that wasn't enough,
because the pclntab itself contains dynamic relocations which are
not applied by the tool. As of Go 1.18 the pclntab is mostly
position independent and does not contain dynamic relocations, so
this should be possible now.

Fixes #17883.
Updates #46639.

Change-Id: I85dc3d50ffcc1a4b187a349479a6a162de1ab2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227483
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/internal/objfile/elf.go
src/cmd/objdump/objdump_test.go