# HG changeset patch # User Tassilo Philipp # Date 1495398107 -7200 # Node ID 943c182692e2289470d75985dd50cc19443eabac # Parent 8bb4618c18d824e5249d51050172d6fb3618308d - configure: noexecstack flag check/search now reflecting what dyncall build needs/does diff -r 8bb4618c18d8 -r 943c182692e2 configure --- a/configure Sat May 20 17:41:08 2017 +0200 +++ b/configure Sun May 21 22:21:47 2017 +0200 @@ -203,44 +203,48 @@ # Assure objects not asking for an execstack (or binary that links dyncall might end # up with one, for no reason). -# We run our .s and .S files through $CC. GCC and others (annoyingly) assume without -# being told explicitly that an executable stack may be required for those. +# We run our .s and .S files through $CC. GCC and others might (annoyingly) assume that +# an executable stack may be required for those, if not told explicitly that it isn't. # Trying to specify this per source via .section .note.GNU-stack,"",... turned out to # be not consistently implemented across our supported platforms and toolchains, and # thus not being portable (on some platforms even resulting in the opposite, the mere # presence of this section, no matter the flags, creating an rwx stack). # So, let's set the needed build flags by running a few tests, if we find any that -# work. +# work (as those also don't always have the intended effect). -#determine_asflags() { -# AS_PROG=".global main\nmain:\n" -# echo "${AS_PROG}" | cc -xassembler -o rwxtest.d.out - -# echo "${AS_PROG}.section .note.GNU-stack,\"\"" | cc -xassembler -o rwxtest.s.out - -# echo "${AS_PROG}" | cc -xassembler -o rwxtest.f.out -Wa,--noexecstack - +RWXTESTPREFIX="rwxtest" # @@@ put this maybe all in Makefile.generic? out of source builds? +for s in S s ; do ( + cd "$BLDTOP" + # asm test file, with main and _main for portability. + (echo '.text';(echo '.globl main';echo 'main:') | sed 'p;s/m/_m/') > $RWXTESTPREFIX.$s -# @@@ find solution for platforms without objdump -RWXTESTBIN="$BLDTOP/rwxtest.out" # @@@ put this maybe all in Makefile.generic? out of source builds? -STACKFLAGS=`make -f - </dev/null -if [ "$STACKFLAGS" = "rw-" ]; then - # platforms differe here, so set them all - printf "ASFLAGS=-Wa,--noexecstack\n" >>$C # common on GNU - printf "ACFLAGS=-Wa,--noexecstack\n" >>$C # specifically for .S.o - printf "AFLAGS=--noexecstack\n" >>$C # for direct assembler invocation -fi -#if echo ".global main\nmain:\n" | cc -xassembler -o rwxtest.f.out -Wa,--noexecstack - -#(which objdump && objdump -p rwxtest.f.out || echo stack flags lookup_err) | grep -i -A1 stack | grep 'flags.*' | sed 's/^.*flags //' -#} + # Check what stack of a built test binary would result in. +# @@@ add xxd hexdump based versions for when objdump is not available; also check for those if we deal with ELF files + STACKFLAGS=`(which objdump && objdump -p $RWXTESTPREFIX.out) | sed -e '/STACK/bx' -e 'd' -e ':x' -e 'N' -e 's/^.*flags[ \t]\([^ \t]*\).*/\1/'` + rm $RWXTESTPREFIX.out $RWXTESTPREFIX.o + if [ "$STACKFLAGS" = "rw-" ]; then + printf "$f\n" + break + fi -#printf "ACFLAGS=-Wa,--noexecstack\n" >>$C -#printf "AFLAGS=--noexecstack\n" >>$C + done + + rm $RWXTESTPREFIX.$s + +) done 2>&1 | grep '^[ASC]\+FLAGS.*noexecstack$' | uniq >>$C + # Generate all makefiles needed @@ -259,3 +263,5 @@ EOF done +echo "Configuration written do $C" +