-
-
Notifications
You must be signed in to change notification settings - Fork 508
Open
Description
Reproducer:
$ cat trivialcgo.go
package main
import "C"
func main() {
}
$ go build -ldflags=-linkmode=internal /opt/opensource/go-test-cases/trivialcgo.go
$ objcopy --remove-section .note.go.buildid trivialcgo
$ patchelf --set-rpath doesntmatter ./trivialcgo$ ./trivialcgo
Segmentation fault (core dumped)
The reason for the crash is seen in readelf -l
:
$ readelf -l ./trivialcgo
...
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
...
LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x04e270 0x04e270 R E 0x1000
DYNAMIC 0x000270 0x0000000000400270 0x0000000000400270 0x000140 0x000140 RW 0x8
...
The PT_DYNAMIC header points into a PT_LOAD section that does not have the W flag, which causes glibc to segv very early in program startup.
sjackman and jirutka
Metadata
Metadata
Assignees
Labels
No labels