Mercurial > pub > dyncall > dyncall
comparison configure @ 267:f8fe0f87b7c1
- removed configure-based checks for using --noexecstack / -Wa,--noexecstack in make A{S,C,}FLAGS variables, b/c inconsistent behaviour across platforms and often unusable, b/c:
* braindead defaults (e.g. ASFLAGS on pretty much everything GNU, used in default suffix rules with *both* cc for .S and as for .s)
* often took decisions on bogus private STACK headers in ELF files, set on platforms that lack any implementation, so pointless
* tests have shown that only some GNU/* platforms and FreeBSD actually make use of this, if at all, that is... and for those, will switch back to .section .note.GNU-stack (next commit)
author | Tassilo Philipp |
---|---|
date | Sat, 27 May 2017 19:18:23 +0200 |
parents | 91fd7be165f1 |
children | 1032015f77ee |
comparison
equal
deleted
inserted
replaced
266:91fd7be165f1 | 267:f8fe0f87b7c1 |
---|---|
198 exit 0 | 198 exit 0 |
199 ;; | 199 ;; |
200 esac | 200 esac |
201 | 201 |
202 | 202 |
203 # Assure objects not asking for an execstack (or binary that links dyncall might end | 203 # removed, b/c platform support not consistent and ELF flags checked often not having any result |
204 # up with one, for no reason). | 204 # |
205 | 205 ## Assure objects not asking for an execstack (or binary that links dyncall might end |
206 # .s.o/.S.o rules often use ${CC} which then invokes the tools needed. GCC and | 206 ## up with one, for no reason). |
207 # others might (annoyingly) assume that an executable stack may be required for | 207 # |
208 # those sources, if not told explicitly that it isn't. | 208 ## .s.o/.S.o rules often use ${CC} which then invokes the tools needed. GCC and |
209 # Neither specifying this per source (e.g. via .section .note.GNU-stack,"",...), nor | 209 ## others might (annoyingly) assume that an executable stack may be required for |
210 # per toolchain flags (e.g. as' --noexecstack) turned out to be portable across our | 210 ## those sources, if not told explicitly that it isn't. |
211 # supported platforms, toolchains, and different versions of the latter (some even | 211 ## Neither specifying this per source (e.g. via .section .note.GNU-stack,"",...), nor |
212 # producing the opposite result). | 212 ## per toolchain flags (e.g. as' --noexecstack) turned out to be portable across our |
213 # Find needed build flags by running a few tests; use default if none result in "rw-". | 213 ## supported platforms, toolchains, and different versions of the latter (some even |
214 | 214 ## producing the opposite result). |
215 RWXTESTPREFIX="rwxtest" # @@@ put this maybe all in Makefile.generic? out of source builds? | 215 ## Find needed build flags by running a few tests; use default if none result in "rw-". |
216 for s in S s ; do ( | 216 # |
217 cd "$BLDTOP" | 217 #RWXTESTPREFIX="rwxtest" # @@@ put this maybe all in Makefile.generic? out of source builds? |
218 # asm test file, with main and _main for portability. | 218 #for s in S s ; do ( |
219 (echo '.text';(echo '.globl main';echo 'main:') | sed 'p;s/m/_m/') > $RWXTESTPREFIX.$s | 219 # cd "$BLDTOP" |
220 | 220 # # asm test file, with main and _main for portability. |
221 # Check var to be used, which depends on inference rules of this platform. E.g. ASFLAGS is only common on GNU, and | 221 # (echo '.text';(echo '.globl main';echo 'main:') | sed 'p;s/m/_m/') > $RWXTESTPREFIX.$s |
222 # on some other platforms only CFLAGS is the only one used, others use AFLAGS with cc and thus need -Wa,... Check | 222 # |
223 # makes use of the config written so far, so use '+=' to not overwrite vars. | 223 # # Check var to be used, which depends on inference rules of this platform. E.g. ASFLAGS is only common on GNU, and |
224 for f in "" "ASFLAGS+=-Wa,--noexecstack" "ACFLAGS+=-Wa,--noexecstack" "AFLAGS+=--noexecstack" "AFLAGS+=-Wa,--noexecstack" "CFLAGS+=-Wa,--noexecstack"; do | 224 # # on some other platforms only CFLAGS is the only one used, others use AFLAGS with cc and thus need -Wa,... Check |
225 # dummy makefile triggering inference rules, reflecting dyncall's build | 225 # # makes use of the config written so far, so use '+=' to not overwrite vars. |
226 make -f - <<MAKEFILE | 226 # for f in "" "ASFLAGS+=-Wa,--noexecstack" "ACFLAGS+=-Wa,--noexecstack" "AFLAGS+=--noexecstack" "AFLAGS+=-Wa,--noexecstack" "CFLAGS+=-Wa,--noexecstack"; do |
227 include $C | 227 # # dummy makefile triggering inference rules, reflecting dyncall's build |
228 $f | 228 # make -f - <<MAKEFILE |
229 # Force dependency via .o, to avoid .[sS].out rules that might be set - also set command as not all platforms set .o.out | 229 #include $C |
230 $RWXTESTPREFIX.out: $RWXTESTPREFIX.o | 230 #$f |
231 \${CC} \${CFLAGS} \${LDFLAGS} $RWXTESTPREFIX.o \${LDLIBS} -o $RWXTESTPREFIX.out | 231 ## Force dependency via .o, to avoid .[sS].out rules that might be set - also set command as not all platforms set .o.out |
232 MAKEFILE | 232 #$RWXTESTPREFIX.out: $RWXTESTPREFIX.o |
233 | 233 # \${CC} \${CFLAGS} \${LDFLAGS} $RWXTESTPREFIX.o \${LDLIBS} -o $RWXTESTPREFIX.out |
234 # Check what stack of a built test binary would result in. | 234 #MAKEFILE |
235 # @@@ add xxd hexdump based versions for when objdump is not available; also check for those if we deal with ELF files | 235 # |
236 # @@@ maybe also limit to ELF files | 236 # # Check what stack of a built test binary would result in. |
237 STACKFLAGS=`(which objdump && objdump -p $RWXTESTPREFIX.out) | sed -e '/STACK/bx' -e 'd' -e ':x' -e 'N' -e 's/^.*flags[ \t]\([^ \t]*\).*/\1/'` | 237 ## @@@ add xxd hexdump based versions for when objdump is not available; also check for those if we deal with ELF files |
238 rm $RWXTESTPREFIX.out $RWXTESTPREFIX.o | 238 ## @@@ maybe also limit to ELF files |
239 if [ "$STACKFLAGS" = "rw-" ]; then | 239 # STACKFLAGS=`(which objdump && objdump -p $RWXTESTPREFIX.out) | sed -e '/STACK/bx' -e 'd' -e ':x' -e 'N' -e 's/^.*flags[ \t]\([^ \t]*\).*/\1/'` |
240 printf "$f\n" | 240 # rm $RWXTESTPREFIX.out $RWXTESTPREFIX.o |
241 break | 241 # if [ "$STACKFLAGS" = "rw-" ]; then |
242 fi | 242 # printf "$f\n" |
243 | 243 # break |
244 done | 244 # fi |
245 | 245 # |
246 rm $RWXTESTPREFIX.$s | 246 # done |
247 | 247 # |
248 ) done 2>&1 | grep '^[ASC]\+FLAGS.*noexecstack$' | uniq >>$C | 248 # rm $RWXTESTPREFIX.$s |
249 # | |
250 #) done 2>&1 | grep '^[ASC]\+FLAGS.*noexecstack$' | uniq >>$C | |
249 | 251 |
250 | 252 |
251 | 253 |
252 # Generate all makefiles needed | 254 # Generate all makefiles needed |
253 | 255 |
263 include $BLDTOP/Makefile.config | 265 include $BLDTOP/Makefile.config |
264 include \${VPATH}/Makefile.generic | 266 include \${VPATH}/Makefile.generic |
265 EOF | 267 EOF |
266 done | 268 done |
267 | 269 |
268 echo "Configuration written do $C" | 270 echo "Configuration written to $C" |
269 | 271 |