Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: bss section offset exceeds the end of its segment #47168

Open
qingyunha opened this issue Jul 13, 2021 · 1 comment · May be fixed by #47169
Open

cmd/link: bss section offset exceeds the end of its segment #47168

qingyunha opened this issue Jul 13, 2021 · 1 comment · May be fixed by #47169

Comments

@qingyunha
Copy link
Contributor

@qingyunha qingyunha commented Jul 13, 2021

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

$ go version
go version devel go1.17-ed01ceaf48 Fri Jun 25 21:07:44 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/taoqy/.cache/go-build"
GOENV="/home/taoqy/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/taoqy/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/taoqy/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io"
GOROOT="/home/taoqy/cc/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/taoqy/cc/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.17-ed01ceaf48 Fri Jun 25 21:07:44 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build911632282=/tmp/go-build -gno-record-gcc-switches"

What did you do?

build a simple hello.go and readelf its binary.

readelf Output
$ readelf -lS  /tmp/hello
There are 16 section headers, starting at offset 0x1c8:

Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000401000 00001000
000000000007d3c7 0000000000000000 AX 0 0 32
[ 2] .rodata PROGBITS 000000000047f000 0007f000
0000000000034f0c 0000000000000000 A 0 0 32
[ 3] .shstrtab STRTAB 0000000000000000 000b3f20
00000000000000b5 0000000000000000 0 0 1
[ 4] .typelink PROGBITS 00000000004b3fe0 000b3fe0
00000000000004d8 0000000000000000 A 0 0 32
[ 5] .itablink PROGBITS 00000000004b44c0 000b44c0
0000000000000058 0000000000000000 A 0 0 32
[ 6] .gosymtab PROGBITS 00000000004b4518 000b4518
0000000000000000 0000000000000000 A 0 0 1
[ 7] .gopclntab PROGBITS 00000000004b4520 000b4520
0000000000058b00 0000000000000000 A 0 0 32
[ 8] .go.buildinfo PROGBITS 000000000050e000 0010e000
0000000000000020 0000000000000000 WA 0 0 16
[ 9] .noptrdata PROGBITS 000000000050e020 0010e020
00000000000105c0 0000000000000000 WA 0 0 32
[10] .data PROGBITS 000000000051e5e0 0011e5e0
0000000000007810 0000000000000000 WA 0 0 32
[11] .bss NOBITS 0000000000525e00 00125e00
000000000002ef08 0000000000000000 WA 0 0 32
[12] .noptrbss NOBITS 0000000000554d20 00154d20
0000000000005360 0000000000000000 WA 0 0 32
[13] .note.go.buildid NOTE 0000000000400f9c 00000f9c
0000000000000064 0000000000000000 A 0 0 4
[14] .symtab SYMTAB 0000000000000000 00126000
000000000000c330 0000000000000018 15 120 8
[15] .strtab STRTAB 0000000000000000 00132330
000000000000afde 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)

Elf file type is EXEC (Executable file)
Entry point 0x45c320
There are 7 program headers, starting at offset 64

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040
0x0000000000000188 0x0000000000000188 R 0x1000
NOTE 0x0000000000000f9c 0x0000000000400f9c 0x0000000000400f9c
0x0000000000000064 0x0000000000000064 R 0x4
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x000000000007e3c7 0x000000000007e3c7 R E 0x1000
LOAD 0x000000000007f000 0x000000000047f000 0x000000000047f000
0x000000000008e020 0x000000000008e020 R 0x1000
LOAD 0x000000000010e000 0x000000000050e000 0x000000000050e000
0x0000000000017e00 0x000000000004c080 RW 0x1000
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x8
LOOS+0x5041580 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x8

Section to Segment mapping:
Segment Sections...
00
01 .note.go.buildid
02 .text .note.go.buildid
03 .rodata .typelink .itablink .gosymtab .gopclntab
04 .go.buildinfo .noptrdata .data .bss .noptrbss
05
06

For example, the .noptrbss section offset is 0x154d20 that is larger than its segment(the fourth segment) end (0x10e000 + 0x17e00)

What did you expect to see?

.bss and .noptrbss both offset at 0x10e000 + 0x17e00

What did you see instead?

.bss and .noptrbss offset exceed 0x10e000 + 0x17e00

qingyunha added a commit to qingyunha/go that referenced this issue Jul 13, 2021
qingyunha added a commit to qingyunha/go that referenced this issue Jul 13, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Jul 13, 2021

Change https://golang.org/cl/334232 mentions this issue: cmd/link: make bss section offset at end of its segment

@cherrymui cherrymui changed the title bss section offset exceeds the end of its segment cmd/link: bss section offset exceeds the end of its segment Jul 13, 2021
@cherrymui cherrymui added this to the Backlog milestone Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants