Skip to content

cmd/link: bad debug_frame section on macOS with buildmode=pie [Debugging] #25841

@aarzilli

Description

@aarzilli

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 darwin/amd64

(also reproduces with go1.11 built from tip)

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/vagrant/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vagrant/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/go-build680864595=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Build any program with go build -gcflags='-N -l' -buildmode pie

What did you expect to see?

debug_info has an entry for main.main that looks like this

 <1><40cda>: Abbrev Number: 2 (DW_TAG_subprogram)
    <40cdb>   DW_AT_name        : (indirect string, offset: 0x29120): main.main
    <40cdf>   DW_AT_low_pc      : 0x100090530
    <40ce7>   DW_AT_high_pc     : 0x100090636
    <40cef>   DW_AT_frame_base  : 1 byte block: 9c      (DW_OP_call_frame_cfa)
    <40cf1>   DW_AT_decl_file   : 0x1
    <40cf5>   DW_AT_external    : 1

but nothing in debug_frame covers anywhere close to the range 0x100090530...0x100090636, for example the first FDE is:

00000014 000000000000002c 00000000 FDE cie=00000000 pc=0000000000002600..0000000000002737
  DW_CFA_def_cfa_offset_sf: 8
  DW_CFA_advance_loc: 23 to 0000000000002617
  DW_CFA_def_cfa_offset_sf: 48
  DW_CFA_advance_loc1: 92 to 0000000000002673
  DW_CFA_def_cfa_offset_sf: 8
  DW_CFA_advance_loc: 1 to 0000000000002674
  DW_CFA_def_cfa_offset_sf: 48
  DW_CFA_advance_loc1: 124 to 00000000000026f0
  DW_CFA_def_cfa_offset_sf: 8
  DW_CFA_advance_loc: 1 to 00000000000026f1
  DW_CFA_def_cfa_offset_sf: 48
  DW_CFA_advance_loc: 60 to 000000000000272d
  DW_CFA_def_cfa_offset_sf: 8
  DW_CFA_advance_loc: 9 to 0000000000002736
  DW_CFA_nop

It seems to me that this is wrong but I could be missing something.

Metadata

Metadata

Assignees

Labels

DebuggingFrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions