Skip to content

Commit 0d542a8

Browse files
committed
Makefile: Add build mode pie
When using the lld linker, compilation with PIC is required. The bfd linker may allow it, but the lld linker requires recompilation with -fPIC if relocation is found in PIE. ``` aarch64-poky-linux-ld.lld: error: relocation R_AARCH64_ABS64 cannot be used against symbol 'type:.eq.os.file'; recompile with -fPIC >>> defined in /tmp/go-link-1382269313/go.o >>> referenced by go.go >>> /tmp/go-link-1382269313/go.o:(.rodata+0x1750) ``` Signed-off-by: mark.yang <[email protected]>
1 parent 0ea5ed0 commit 0d542a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BUILDTAGS=
66
RUNTIME ?= runc
77
COMMIT ?= $(shell git describe --dirty --long --always --tags 2> /dev/null)
88
VERSION := ${shell cat ./VERSION}
9-
BUILD_FLAGS := -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION)" $(EXTRA_FLAGS)
9+
BUILD_FLAGS := -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) -buildmode=pie" $(EXTRA_FLAGS)
1010
STATIC_BUILD_FLAGS := -tags "$(BUILDTAGS) netgo osusergo" -ldflags "-extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION)" $(EXTRA_FLAGS)
1111
VALIDATION_TESTS ?= $(patsubst %.go,%.t,$(shell find ./validation/ -name *.go | grep -v util))
1212

0 commit comments

Comments
 (0)