2 # Copyright (c) 2016 Apple Inc. All rights reserved.
4 # @APPLE_LICENSE_HEADER_START@
6 # This file contains Original Code and/or Modifications of Original Code
7 # as defined in and that are subject to the Apple Public Source License
8 # Version 2.0 (the 'License'). You may not use this file except in
9 # compliance with the License. Please obtain a copy of the License at
10 # http://www.opensource.apple.com/apsl/ and read it before using this
13 # The Original Code and all software distributed under the License are
14 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 # Please see the License for the specific language governing rights and
19 # limitations under the License.
21 # @APPLE_LICENSE_HEADER_END@
24 include ${TESTROOT}/include/common.makefile
27 # Check interaction of -section_rename and -move_to_r[ow]_segment
33 ${CC} ${CCFLAGS} main.c -c -o main.o
34 ${CC} ${CCFLAGS} foo1.c -c -o foo1.o
35 ${CC} ${CCFLAGS} foo2.c -c -o foo2.o
36 libtool -static foo1.o foo2.o -o libfoo.a
37 ${LD} -arch ${ARCH} main.o -force_load libfoo.a \
38 -preload -o main.preload \
39 -e _main -trace_symbol_layout \
40 -move_to_ro_segment __TMP spec.list \
41 -rename_section __TMP __text __TEXT spec \
42 -move_to_ro_segment __TMP2 foo.list \
43 -rename_section __TMP2 __text __TEXT libfoo \
44 -move_to_rw_segment __TMPD hot.list \
45 -rename_section __TMPD __data __DATA hot \
46 -rename_section __TMPD __common __DATA hot \
48 nm -m main.preload | grep _s1 | grep __TEXT | grep spec | ${FAIL_IF_EMPTY}
49 nm -m main.preload | grep _s2 | grep __TEXT | grep spec | ${FAIL_IF_EMPTY}
50 nm -m main.preload | grep _def | grep __DATA | grep hot | ${FAIL_IF_EMPTY}
51 nm -m main.preload | grep _com3 | grep __DATA | grep hot | ${FAIL_IF_EMPTY}
52 nm -m main.preload | grep _foo1 | grep __TEXT | grep libfoo | ${FAIL_IF_EMPTY}
53 nm -m main.preload | grep _foo2 | grep __TEXT | grep libfoo | ${FAIL_IF_EMPTY}
57 rm -f main.preload main.o foo1.o foo2.o libfoo.a placement.log