##
-# Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+# Copyright (c) 2005-2008 Apple Inc. All rights reserved.
#
# @APPLE_LICENSE_HEADER_START@
#
TESTROOT = ../..
include ${TESTROOT}/include/common.makefile
-# Test the ld commands -stack_addr, -stack_size
-# Test using -stack_size only
+# Test the ld option -stack_size adds a custom stack segment
+ifeq (${FILEARCH},arm)
+ STACK_ADDR = 0x30000000
+ STACK_SIZE = 0x05000000
+ STACK_TOP = 0x2a000000
+else
ifeq (,${findstring 64,$(ARCH)})
STACK_ADDR = 0xC0000000
STACK_SIZE = 0x05000000
STACK_TOP = 0xbb000000
else
-#ifeq (${ARCH},x86_64)
STACK_ADDR = 0x0007fff5fc000000
STACK_TOP = 0x00007fff57000000
STACK_SIZE = 0x0000000005000000
-#else
- #STACK_ADDR = 0x0007ffff00000000
- #STACK_TOP = 0x0007fffefb000000
- #STACK_SIZE = 0x0000000005000000
-#endif
+endif
endif
run: all
-
-
all:
-# info seems to not work, use warning:
- ${CC} ${CCFLAGS} -c main.c -o main-${ARCH}.o
- ${FAIL_IF_BAD_OBJ} main-${ARCH}.o
-
-
- ${LD} -arch ${ARCH} \
- -stack_size ${STACK_SIZE} \
- -lcrt1.o -lSystem \
- main-${ARCH}.o -o main \
- 2>lderr.out
-
-# Can check warning if desired.
-#ifeq (,${findstring 64,$(ARCH)})
-# grep "warning no -stack_size specified using the default size" lderr.out | ${FAIL_IF_EMPTY}
-#else
-# grep "failed: -stack_addr must be used with -stack_size" lderr.out | ${FAIL_IF_EMPTY}
-#endif
-
-# Check for __UNIXSTACK section in object, check that it has the correct value
- ${FAIL_IF_ERROR} ${OTOOL} -l main>ldcmds.out
- (echo '1,/^[ ]*segname __UNIXSTACK$$/-d'; echo '/^[ ]*segname /,$$d'; echo w; echo q) | ed ldcmds.out >/dev/null
- grep __UNIXSTACK ldcmds.out | ${FAIL_IF_EMPTY}
- grep " vmsize[ ]*${STACK_SIZE}" ldcmds.out | ${FAIL_IF_EMPTY}
- grep " vmaddr[ ]*${STACK_TOP}" ldcmds.out | ${FAIL_IF_EMPTY}
+ ${CC} ${CCFLAGS} main.c -o main -Wl,-stack_size,${STACK_SIZE}
+ # Check for __UNIXSTACK section in object, check that it has the correct value
+ otool -l main | grep -A6 __UNIXSTACK > main.otool
+ grep " vmsize[ ]*${STACK_SIZE}" main.otool | ${FAIL_IF_EMPTY}
+ grep " vmaddr[ ]*${STACK_TOP}" main.otool | ${FAIL_IF_EMPTY}
${PASS_IFF_GOOD_MACHO} main
clean:
- rm -rf *.o *.err *.out main
+ rm -rf main main.otool