Makefile.compile: generate PIE for native

* In this way, OS will load native programs to high virtual address.
  This makes it possible for native AM to use low virtual address.
This commit is contained in:
Zihao Yu 2018-04-04 10:04:06 +08:00
parent 8ed9b31dd8
commit 7e5e45afd0
2 changed files with 8 additions and 1 deletions

View File

@ -30,6 +30,13 @@ CFLAGS += -std=gnu99 -O2 -MMD -Wall -Werror -ggdb $(INCLUDES) -D$(ISA_DEF) -fn
CXXFLAGS += -std=c++11 -O2 -MMD -Wall -Werror -ggdb $(INCLUDES) -D$(ISA_DEF) -fno-builtin
ASFLAGS += -MMD $(INCLUDES) -D$(ISA_DEF)
ifeq ($(ISA), native)
CFLAGS_COMMON = -fpie
CFLAGS += $(CFLAGS_COMMON)
CXXFLAGS += $(CFLAGS_COMMON)
ASFLAGS += -fpie -pie
endif
ifeq ($(ISA), mips32)
CFLAGS_COMMON = -fno-pic -static -fno-strict-aliasing -fno-builtin -fno-stack-protector -fno-delayed-branch -mno-abicalls -march=mips32 -mno-check-zero-division -EL -mno-llsc -mno-imadd -mno-mad
CFLAGS += $(CFLAGS_COMMON)

View File

@ -3,4 +3,4 @@
DEST=$1
shift
g++ -o "$DEST" -Wl,--start-group $@ -Wl,--end-group -lSDL2 -lGL
g++ -pie -o "$DEST" -Wl,--start-group $@ -Wl,--end-group -lSDL2 -lGL -lrt