瀏覽代碼

[Pal/Makefiles] Force -no-pie when building PAL tests

PAL loader cannot relocate executables. Thus, PIE executables (per
default GCC setting on Ubuntu 18.04) will crash if no other loader
(e.g., Glibc loader) is involved. Since PAL tests are only for
internal testing purposes, we simply make these tests position-
dependent (adding -no-pie to CFLAGS).
Chia-Che Tsai 6 年之前
父節點
當前提交
914c6d8c86
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      Pal/regression/Makefile
  2. 1 1
      Pal/test/Makefile

+ 2 - 2
Pal/regression/Makefile

@@ -1,7 +1,7 @@
 include ../src/Makefile.Host
 
 CC	= gcc
-CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx \
+CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx -no-pie \
 	  -I../include/pal -I../lib
 
 preloads    = $(patsubst %.c,%,$(wildcard *.so.c))
@@ -53,7 +53,7 @@ ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 $(preloads): %.so: %.so.c ../src/user_shared_start.o \
 	$(graphene_lib) $(pal_lib) ../include/pal/pal.h
 	@echo [ $@ ]
-	@$(CC) -shared -fPIC $(CFLAGS) $^ -o $@
+	@$(CC) -shared -fPIC $(filter-out -no-pie,$(CFLAGS)) $^ -o $@
 
 $(executables): %: %.c ../src/user_start.o \
 	$(graphene_lib) $(pal_lib) $(preloads) ../include/pal/pal.h

+ 1 - 1
Pal/test/Makefile

@@ -1,7 +1,7 @@
 include ../src/Makefile.Host
 
 CC	= gcc
-CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib \
+CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
 	  -I../include/pal -I../lib
 
 .PHONY: default