Makefile: use -fPIC instead of -fPIE
According to the gcc docs:
-fPIE
These options are similar to -fpic and -fPIC, but generated position
independent code can be only linked into executables
Example failure when linking against shared library:
FAILED: lib/libbrillo-core.so
x86_64-cros-linux-gnu-clang++ -shared -Wl,-O2 -Wl,--as-needed
-Wl,--gc-sections -Wl,--icf=all -Wl,-z,relro -Wl,-z,noexecstack
-Wl,-z,now -Wl,--as-needed --sysroot=/build/hatch -o
./lib/libbrillo-core.so -Wl,-soname=libbrillo-core.so
@lib/libbrillo-core.so.rsp
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol
subprocess_stdin; recompile with -fPIC
>>> defined in
/build/hatch/usr/lib/../lib64/libvboot_host.a(subprocess.o)
>>> referenced by subprocess.c:278 (host/lib/subprocess.c:278)
>>> subprocess.o:(subprocess_run) in archive
/build/hatch/usr/lib/../lib64/libvboot_host.a
BRANCH=none
BUG=b:174578361
TEST=FEATURES="test" emerge-hatch vboot_reference
Change-Id: I5cda8dbe87d20d1b4b659459d861bc04f492e3e5
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2568259
Commit-Queue: Julius Werner <jwerner@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/Makefile b/Makefile
index 5de9f57..df7e404 100644
--- a/Makefile
+++ b/Makefile
@@ -259,7 +259,7 @@
ifeq (${FIRMWARE_ARCH},)
# Creates position independent code for non firmware target.
-CFLAGS += -fPIE
+CFLAGS += -fPIC
endif
CFLAGS += -D_GNU_SOURCE