Fix check-execstack test

This commit is contained in:
Andreas Schwab 2011-01-13 16:21:55 -05:00 committed by Ulrich Drepper
parent 8cf8ce1702
commit 68dc949774
3 changed files with 31 additions and 18 deletions

View File

@ -1,3 +1,14 @@
2010-12-28 Andreas Schwab <schwab@linux-m68k.org>
* elf/Makefile (check-execstack): Revert last change. Depend on
check-execstack.h.
(check-execstack.h): New target.
(generated): Add check-execstack.h.
* elf/check-execstack.c: Include "check-execstack.h".
(main): Revert last change.
(handle_file): Return zero if GNU_STACK is absent and
DEFAULT_STACK_PERMS doesn't include PF_X.
2011-01-13 Ulrich Drepper <drepper@gmail.com> 2011-01-13 Ulrich Drepper <drepper@gmail.com>
* sysdeps/posix/spawni.c (__spawni): Don't fail if close file action * sysdeps/posix/spawni.c (__spawni): Don't fail if close file action

View File

@ -898,15 +898,17 @@ check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
$(objpfx)check-textrel: check-textrel.c $(objpfx)check-textrel: check-textrel.c
$(native-compile) $(native-compile)
check-execstack-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99 check-execstack-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99 \
# Perform the same operation as $(native-compile) but add the sysdeps $(objpfx:%/=-I%)
# directories as header search locations. $(objpfx)check-execstack: check-execstack.c $(objpfx)check-execstack.h
$(objpfx)check-execstack: check-execstack.c $(native-compile)
$(objpfx)check-execstack.h: $(first-word $(wildcard $(sysdirs:%=%/stackinfo.h)))
$(make-target-directory) $(make-target-directory)
$(patsubst %/,cd % &&,$(objpfx)) \ { echo '#include <stackinfo.h>'; echo '@@@DEFAULT_STACK_PERMS@@@'; } | \
$(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \ $(CC) $(CFLAGS) $(CPPFLAGS) -E -x c-header - | \
$(addprefix -I$(shell pwd)/,$(sysdirs)) -I$(shell pwd) \ sed -n -e 's/^@@@\(.*\)@@@/#define DEFAULT_STACK_PERMS \1/p' > $@T
$(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F) mv -f $@T $@
generated += check-execstack.h
check-localplt-CFLAGS = -O -Wall -D_GNU_SOURCE -std=gnu99 check-localplt-CFLAGS = -O -Wall -D_GNU_SOURCE -std=gnu99
$(objpfx)check-localplt: check-localplt.c $(objpfx)check-localplt: check-localplt.c

View File

@ -26,7 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <stackinfo.h> #include "check-execstack.h"
#ifdef BITS #ifdef BITS
@ -92,8 +92,13 @@ AB(handle_file) (const char *fname, int fd)
return 0; return 0;
} }
printf ("%s: no PT_GNU_STACK entry\n", fname); if (DEFAULT_STACK_PERMS & PF_X)
return 1; {
printf ("%s: no PT_GNU_STACK entry\n", fname);
return 1;
}
return 0;
} }
# undef BITS # undef BITS
@ -151,13 +156,8 @@ main (int argc, char *argv[])
int cnt; int cnt;
int result = 0; int result = 0;
/* We can return successfully, i.e., not fail, if PF_X isn't present. If it for (cnt = 1; cnt < argc; ++cnt)
* is present then check for the GNU_STACK header. */ result |= handle_file (argv[cnt]);
if (DEFAULT_STACK_PERMS & PF_X)
{
for (cnt = 1; cnt < argc; ++cnt)
result |= handle_file (argv[cnt]);
}
return result; return result;
} }
#endif #endif