2 # Copyright (c) 2005-2010 Apple Computer, 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@
25 # This test verifies ld -preload support required for mtoc
26 # to create a PE/COFF image that will work with EFI.
27 # The mach-o file and pecoff files are parsed with the
28 # test.py script to make sure the images look OK.
30 # Note: We should fail with an error condition if any of the all:
32 # Note: Currently does not support ARM due to no ARM support in
33 # /usr/local/efi/bin/objdump
36 include ${TESTROOT}/include/common.makefile
38 LOCAL_CC_FLAGS = -g -Os -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces
45 OBJ_DUMP_ARCH=efi-app-x86-64
48 OBJ_DUMP_ARCH=efi-app-ia32
49 LD_ARG=-read_only_relocs suppress
58 ${CC} -arch $(ARCH) -o LibTest1.obj $(LOCAL_CC_FLAGS) -c LibTest.c
59 libtool -static -o LibTest1.lib LibTest1.obj
60 ${CC} -arch $(ARCH) -o MtocTest1.obj $(LOCAL_CC_FLAGS) -c MtocTest.c
61 libtool -static -o MtocTest1.lib MtocTest1.obj
62 ${LD} -arch $(ARCH) -o MtocTest1.macho -u __ModuleEntryPoint -e __ModuleEntryPoint $(LD_ARG) -preload -segalign 0x20 -pie -seg1addr 0x240 -map MtocTest1.map LibTest1.lib MtocTest1.lib
63 /usr/local/efi/bin/mtoc -subsystem application -align 0x20 -d MtocTest1.macho MtocTest1.macho MtocTest1.pecoff
64 otool -rR MtocTest1.macho > otool-reloc.log
65 otool -l MtocTest1.macho > otool-load.log
66 /usr/local/efi/bin/objdump -b $(OBJ_DUMP_ARCH) -x MtocTest1.pecoff > objdump-raw.log
67 ${PASS_IFF_SUCCESS} ./mtoctest.py --arch $(ARCH)
71 rm -rf *.pecoff *.macho *.obj *.log *.lib *.map