[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proof of concept: disable PIE when linking vacall tests

From: Josh Elsasser
Subject: Proof of concept: disable PIE when linking vacall tests
Date: Wed, 20 Nov 2019 20:48:23 -0800
User-agent: Mutt/1.5.22 (2013-10-16)

Some platforms, such as OpenBSD (and some Linux distributions?), build
PIC executables by default. The vacall tests fail at least on OpenBSD
x86-64 and powerpc unless PIE is disabled.

The following patch works for me, but I assume will break any platform
where the compiler doesn't understand the -nopie flag. Perhaps there
is an existing autoconf recipe for detecting how to disable PIE?

diff --git vacall/ vacall/
index bd6d4bd..ee70cd3 100644
--- vacall/
+++ vacall/
@@ -280,13 +280,13 @@ minitests.s : $(srcdir)/minitests.c $(srcdir)/tests.c 
        $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/minitests.c
 minitests : minitests.@OBJEXT@ libvacall.a
-       $(CC) $(CFLAGS) @GCC_X_NONE@ minitests.@OBJEXT@ libvacall.a $(LDFLAGS) 
-o minitests
+       $(CC) $(CFLAGS) -nopie @GCC_X_NONE@ minitests.@OBJEXT@ libvacall.a 
$(LDFLAGS) -o minitests
 minitests-c++.@OBJEXT@ : $(srcdir)/ $(srcdir)/minitests.c 
$(srcdir)/tests.c $(srcdir)/vacall.h
        $(CXX) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -c $(srcdir)/
 minitests-c++ : minitests-c++.@OBJEXT@ libvacall.a
-       $(CXX) $(CXXFLAGS) @GCC_X_NONE@ minitests-c++.@OBJEXT@ libvacall.a 
$(LDFLAGS) -o minitests-c++
+       $(CXX) $(CXXFLAGS) -nopie @GCC_X_NONE@ minitests-c++.@OBJEXT@ 
libvacall.a $(LDFLAGS) -o minitests-c++
 check : all minitests
        ./minitests > minitests.out
@@ -304,7 +304,7 @@ tests.s : $(srcdir)/tests.c $(srcdir)/vacall.h
        $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/tests.c
 tests : tests.@OBJEXT@ libvacall.a
-       $(CC) $(CFLAGS) @GCC_X_NONE@ tests.@OBJEXT@ libvacall.a $(LDFLAGS) -o 
+       $(CC) $(CFLAGS) -nopie @GCC_X_NONE@ tests.@OBJEXT@ libvacall.a 
$(LDFLAGS) -o tests
 extracheck : all tests
        ./tests > tests.out

reply via email to

[Prev in Thread] Current Thread [Next in Thread]