From ec8f0a046faa10b0c52155370aba6cc2ca0c4e64 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 18 Nov 2010 05:17:29 +0000 Subject: [PATCH] Libsystem-159.tar.gz --- CommPageSymbols.st | 34 ----- CompatibilityHacks.c | 37 ++++++ GNUmakefile | 14 +-- Info.plist | 2 +- Makefile | 95 ++++++++------ Platforms/AppleTV/Makefile.inc | 12 -- Platforms/AppleTV/System.order | 1 - Platforms/MacOSX/Makefile.inc | 3 - Platforms/MacOSX/System.order | 2 - Platforms/iPhone/Makefile.inc | 3 - init.c | 152 +++++++++++++++++++++++ libsys/Makefile | 116 ------------------ libsys/build-libc.pl | 218 --------------------------------- optionallibs | 18 +++ requiredlibs | 12 ++ 15 files changed, 283 insertions(+), 436 deletions(-) delete mode 100644 CommPageSymbols.st create mode 100644 CompatibilityHacks.c delete mode 100644 Platforms/AppleTV/Makefile.inc delete mode 120000 Platforms/AppleTV/System.order create mode 100644 init.c delete mode 100644 libsys/Makefile delete mode 100755 libsys/build-libc.pl create mode 100644 optionallibs create mode 100644 requiredlibs diff --git a/CommPageSymbols.st b/CommPageSymbols.st deleted file mode 100644 index 0215740..0000000 --- a/CommPageSymbols.st +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - * This file creates a .o file containing the comm page symbols that gdb - * can use. It is placed in a special segment within libSystem. - */ - -#define __APPLE_API_PRIVATE -#define __COMM_PAGE_SYMBOLS - -#include "machine/cpu_capabilities.h" diff --git a/CompatibilityHacks.c b/CompatibilityHacks.c new file mode 100644 index 0000000..ac9bb5f --- /dev/null +++ b/CompatibilityHacks.c @@ -0,0 +1,37 @@ +// See: , , + +#include + +#if __i386__ || __x86_64__ + +#define SYM(sym) \ + __asm__(".globl R8289209$_" #sym "; R8289209$_" #sym ": jmp _" #sym); + +/****************/ + +SYM(close); +SYM(fork); +SYM(fsync); +SYM(getattrlist); +SYM(getrlimit); +SYM(getxattr); +SYM(open); +SYM(pthread_attr_destroy); +SYM(pthread_attr_init); +SYM(pthread_attr_setdetachstate); +SYM(pthread_create); +SYM(pthread_mutex_lock); +SYM(pthread_mutex_unlock); +SYM(pthread_self); +SYM(ptrace); +SYM(read); +SYM(setattrlist); +SYM(setrlimit); +SYM(sigaction); +SYM(stat); +SYM(sysctl); +SYM(time); +SYM(unlink); +SYM(write); + +#endif diff --git a/GNUmakefile b/GNUmakefile index 001973c..a875175 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -59,7 +59,7 @@ endif BSD_LIBS = c info m pthread dbm poll dl rpcsvc proc FPATH = /System/Library/Frameworks/System.framework -build:: fake libSystem +build:: libSystem @set -x && \ cd $(DSTROOT)/usr/lib && \ for i in $(BSD_LIBS); do \ @@ -80,15 +80,7 @@ build:: fake libSystem for S in $(SUFFIX); do \ $(LN) -sf ../../../../../../usr/lib/libSystem.$(VersionLetter)$$S.dylib System$$S || exit 1; \ done && \ - $(CP) $(SRCROOT)/Info.plist Resources - -# 4993197: force dependency generation for libsyscall.a -fake: - @set -x && \ - cd $(OBJROOT) && \ - $(ECHO) 'main() { __getpid(); return 0; }' > fake.c && \ - $(CC) -c $(RC_CFLAGS) fake.c && \ - $(LD) -r -o fake $(foreach ARCH,$(RC_ARCHS),-arch $(ARCH)) fake.o -lsyscall -L$(LIBSYS) + plutil -convert binary1 -o Resources/Info.plist $(SRCROOT)/Info.plist libc: $(MKDIR) '$(OBJROOT)/libc' @@ -100,7 +92,7 @@ libc: SRCROOT='$(SRCROOT)' \ SYMROOT='$(SYMROOT)' -libSystem: libc +libSystem: $(MKDIR) '$(OBJROOT)/libSystem' $(BSDMAKE) install \ FEATURE_LIBMATHCOMMON=$(FEATURE_LIBMATHCOMMON) \ diff --git a/Info.plist b/Info.plist index 32c504a..045ff71 100644 --- a/Info.plist +++ b/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 10.6 + 11 CFBundleSignature ???? CarbonLazyValues diff --git a/Makefile b/Makefile index dcfb8f8..c94a129 100644 --- a/Makefile +++ b/Makefile @@ -6,27 +6,55 @@ NAME = $(NAME0).$(VersionLetter) # for now, use the default compiler MYCC := $(CC) +.if $(RC_TARGET_CONFIG) == iPhone MYCCLIBS = -lgcc -RTLIBS = -lcompiler_rt -NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w -.ifdef ALTUSRLOCALLIBSYSTEM -LIBSYS = $(ALTUSRLOCALLIBSYSTEM) -.else -LIBSYS = $(SDKROOT)/usr/local/lib/system .endif +RTLIBS = +NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w SLFS_F_PH = $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders +CODESIGN != xcrun -find codesign .ifdef SDKROOT SDKROOTCFLAGS = -isysroot '$(SDKROOT)' SDKROOTLDFLAGS = -Wl,-syslibroot,'$(SDKROOT)' .endif ORDERFILES = -Wl,-order_file,$(SRCROOT)/SystemInit.order -Wl,-order_file,$(PLATFORM_ORDER_FILE) -LIBS = -lc -lcommonCrypto -ldyldapis\ - -linfo -ldns_sd -lm -lmacho\ - -lnotify -lkeymgr -llaunch \ - -lcopyfile -lremovefile -CONDITIONALLIBS = unc sandbox quarantine closure cache dispatch unwind \ - dnsinfo -LIBSCONDITIONAL != for L in $(CONDITIONALLIBS); do tconf -q --test usr_local_lib_system_Archive:lib$$L && $(ECHO) -l$$L; done + +.ifdef ALTUSRLOCALLIBSYSTEM +LIBSYS = $(ALTUSRLOCALLIBSYSTEM) +.else +LIBSYS = $(SDKROOT)/usr/local/lib/system +.endif +.ifdef ALTUSRLIBSYSTEM +LSYS = $(ALTUSRLIBSYSTEM) +.else +LSYS = $(SDKROOT)/usr/lib/system +.endif + +ACTUALLIBS = $(SYMROOT)/actuallibs +ALLLIBS = $(SYMROOT)/alllibs +FROMUSRLIBSYSTEM = $(SYMROOT)/fromusrlibsystem +FROMUSRLOCALLIBSYSTEM = $(SYMROOT)/fromusrlocallibsystem +INUSRLIBSYSTEM = $(SYMROOT)/inusrlibsystem +INUSRLOCALLIBSYSTEM = $(SYMROOT)/inusrlocallibsystem +MISSINGLIBS = $(SYMROOT)/missinglibs +OPTIONALLIBS = $(SRCROOT)/optionallibs +POSSIBLEUSRLOCALLIBSYSTEM = $(SYMROOT)/possibleusrlocallibsystem +REQUIREDLIBS = $(SRCROOT)/requiredlibs + +$(MISSINGLIBS): + cat $(REQUIREDLIBS) $(OPTIONALLIBS) | sort > $(ALLLIBS) + cd $(LSYS) && ls lib*.dylib | sed -E -e 's/^lib//' -e 's/\..*$$//' -e 's/_(debug|profile|static)$$//' | sort -u > $(INUSRLIBSYSTEM) + cd $(LIBSYS) && ls lib*.a | sed -E -e 's/^lib//' -e 's/\..*$$//' -e 's/_(debug|profile|static)$$//' | sort -u > $(INUSRLOCALLIBSYSTEM) + comm -12 $(ALLLIBS) $(INUSRLIBSYSTEM) > $(FROMUSRLIBSYSTEM) + comm -12 $(ALLLIBS) $(INUSRLOCALLIBSYSTEM) > $(POSSIBLEUSRLOCALLIBSYSTEM) + comm -13 $(FROMUSRLIBSYSTEM) $(POSSIBLEUSRLOCALLIBSYSTEM) > $(FROMUSRLOCALLIBSYSTEM) + cat $(FROMUSRLIBSYSTEM) $(FROMUSRLOCALLIBSYSTEM) | sort > $(ACTUALLIBS) + comm -23 $(REQUIREDLIBS) $(ACTUALLIBS) > $(MISSINGLIBS) + @if [ -s $(MISSINGLIBS) ]; then \ + echo '*** missing required libs ***' && \ + cat $(MISSINGLIBS) && \ + exit 1; \ + fi ; # These variables are to guarantee that the left-hand side of an expression is # always a variable @@ -48,7 +76,7 @@ install: BI-install-$(F) .endif # RC_ProjectName .for A in $(RC_ARCHS) -OBJS-$(A) = $(OBJROOT)/$(A)/SystemMath.o $(OBJROOT)/$(A)/System_vers.o +OBJS-$(A) = $(OBJROOT)/$(A)/SystemMath.o $(OBJROOT)/$(A)/CompatibilityHacks.o $(OBJROOT)/$(A)/System_vers.o $(OBJROOT)/$(A)/init.o .endfor # RC_ARCHS .for F in $(FORMS) @@ -57,9 +85,6 @@ SUFFIX$(F) = .else SUFFIX$(F) = _$(F) .endif -.if !empty(FEATURE_LIBMATHCOMMON) -LIBMATHCOMMON$(F) = -L/usr/lib/system -sub_library libmathCommon$(SUFFIX$(F)) -lmathCommon$(SUFFIX$(F)) -.endif LIPOARGS$(F) != $(PERL) -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).dylib\"), qw($(RC_ARCHS))))' .for A in $(RC_ARCHS) @@ -74,25 +99,22 @@ build-$(F): $(DSYMUTIL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib" .for A in $(RC_ARCHS) +# Hardcode libc.a for now. This will have to be changed when libc becomes +# its own dylib. LINKDYLIB-$(F)-$(A) = $(MYCC) -dynamiclib -arch $(A) -pipe $(SDKROOTLDFLAGS) \ -o '$(OBJROOT)/$(A)/$(F)/$(NAME)$(SUFFIX$(F)).dylib' \ -compatibility_version 1 -current_version $(Version) \ -install_name /usr/lib/$(NAME)$(SUFFIX$(F)).dylib \ - -nodefaultlibs -all_load -multi_module -Wl,-search_paths_first \ - -segcreate __DATA __commpage $(OBJROOT)/$(A)/CommPageSymbols.o \ + -nodefaultlibs -Wl,-search_paths_first \ $(ORDERFILES) $(SKDROOTLDFLAGS) $(OBJS-$(A)) \ - -L$(DSTROOT)/usr/local/lib/system -L$(LIBSYS) $(LIBMATHCOMMON$(F)) \ - $(LIBS:C/$/$(SUFFIX$(F))/) $(LIBSCONDITIONAL:C/$/$(SUFFIX$(F))/) - -build-$(A)-$(F): $(OBJROOT)/$(A)/$(F) $(OBJROOT)/$(A)/CommPageSymbols.o $(OBJS-$(A)) - @$(ECHO) $(LINKDYLIB-$(F)-$(A)) $(RTLIBS) && \ - if $(LINKDYLIB-$(F)-$(A)) $(RTLIBS); then \ - $(ECHO) -n; \ - else \ - $(ECHO) '*** Failed. Retrying with -lgcc ***' && \ - $(ECHO) $(LINKDYLIB-$(F)-$(A)) $(MYCCLIBS) && \ - $(LINKDYLIB-$(F)-$(A)) $(MYCCLIBS); \ - fi + -L$(LSYS) -L$(LIBSYS) $(LIBMATHCOMMON$(F)) \ + `sed 's/.*/-Wl,-reexport-l&/' $(FROMUSRLIBSYSTEM)` \ + `sed -e '/^c$$/d' -e 's|.*|-Wl,-force_load,$(LIBSYS)/lib&$(SUFFIX$(F)).a|' $(FROMUSRLOCALLIBSYSTEM)` + +build-$(A)-$(F): $(OBJROOT)/$(A)/$(F) $(OBJS-$(A)) $(MISSINGLIBS) + @$(ECHO) '=========================================' + @$(ECHO) $(LINKDYLIB-$(F)-$(A)) $(RTLIBS) $(MYCCLIBS) + @$(LINKDYLIB-$(F)-$(A)) $(RTLIBS) $(MYCCLIBS) $(OBJROOT)/$(A)/$(F): $(MKDIR) '$(.TARGET)' @@ -113,16 +135,18 @@ $(OBJROOT)/System_vers.c: $(SED) -e 's/SGS_VERS/SYSTEM_VERS_STRING/' -e 's/VERS_NUM/SYSTEM_VERS_NUM/' > $(.TARGET) .for A in $(RC_ARCHS) -$(OBJROOT)/$(A)/CommPageSymbols.o: $(SRCROOT)/CommPageSymbols.st - $(MYCC) -c -o '$(.TARGET:R)_intermediate.$(.TARGET:E)' -arch $(A) -x assembler-with-cpp $(CFLAGS) '$(.ALLSRC)' - $(LD) -arch $(A) -r -seg1addr $(SEG1ADDR_$(A:C/^armv.*$/arm/)) '$(.TARGET:R)_intermediate.$(.TARGET:E)' -o '$(.TARGET)' - $(OBJROOT)/$(A)/SystemMath.o: $(SRCROOT)/SystemMath.s $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)' +$(OBJROOT)/$(A)/CompatibilityHacks.o: $(SRCROOT)/CompatibilityHacks.c + $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)' + $(OBJROOT)/$(A)/System_vers.o: $(OBJROOT)/System_vers.c $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)' +$(OBJROOT)/$(A)/init.o: $(SRCROOT)/init.c + $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)' + .endfor # RC_ARCHS installhdrs: @@ -135,6 +159,7 @@ BI-install-$(F): build-$(F) $(STRIP) -S "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib" $(CHMOD) a-w "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib" $(LN) -sf "$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib/$(NAME0)$(SUFFIX$(F)).dylib" + $(CODESIGN) -s - "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib" .endfor # FORMS install-all: build diff --git a/Platforms/AppleTV/Makefile.inc b/Platforms/AppleTV/Makefile.inc deleted file mode 100644 index 2ab871c..0000000 --- a/Platforms/AppleTV/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# -# Selectable features for AppleTV -# - -# Build _debug.dylib -FEATURE_DEBUG_DYLIB = 1 - -# Link libmathCommon -FEATURE_LIBMATHCOMMON = 1 - -# Build _profile.dylib -FEATURE_PROFILE_DYLIB = 1 diff --git a/Platforms/AppleTV/System.order b/Platforms/AppleTV/System.order deleted file mode 120000 index dc5064b..0000000 --- a/Platforms/AppleTV/System.order +++ /dev/null @@ -1 +0,0 @@ -./MacOSX/System.order \ No newline at end of file diff --git a/Platforms/MacOSX/Makefile.inc b/Platforms/MacOSX/Makefile.inc index ef7e6be..ccf3402 100644 --- a/Platforms/MacOSX/Makefile.inc +++ b/Platforms/MacOSX/Makefile.inc @@ -5,9 +5,6 @@ # Build _debug.dylib FEATURE_DEBUG_DYLIB = 1 -# Link libmathCommon -FEATURE_LIBMATHCOMMON = 1 - # Build _profile.dylib FEATURE_PROFILE_DYLIB = 1 diff --git a/Platforms/MacOSX/System.order b/Platforms/MacOSX/System.order index 18d2515..997d3cb 100644 --- a/Platforms/MacOSX/System.order +++ b/Platforms/MacOSX/System.order @@ -134,7 +134,6 @@ _pthread_is_threaded_np _task_get_special_port _bootstrap_check_in _vproc_mig_check_in -___commpage_dsmos _malloc_good_size _szone_good_size _opendir$UNIX2003 @@ -219,7 +218,6 @@ _getsectdata _getsectbyname _getegid _gettimeofday -___commpage_gettimeofday _strlcpy _strlcat _setenv$UNIX2003 diff --git a/Platforms/iPhone/Makefile.inc b/Platforms/iPhone/Makefile.inc index a841f8e..ba03d14 100644 --- a/Platforms/iPhone/Makefile.inc +++ b/Platforms/iPhone/Makefile.inc @@ -5,8 +5,5 @@ # Build _debug.dylib #FEATURE_DEBUG_DYLIB = 1 -# Link libmathCommon -#FEATURE_LIBMATHCOMMON = 1 - # Build _profile.dylib #FEATURE_PROFILE_DYLIB = 1 diff --git a/init.c b/init.c new file mode 100644 index 0000000..a78293c --- /dev/null +++ b/init.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2007, 2008 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifdef __DYNAMIC__ + +#include // for TARGET_OS_EMBEDDED + +#include <_libkernel_init.h> +#include + +struct ProgramVars; /* forward reference */ + +// system library initialisers +extern void bootstrap_init(void); // from liblaunch.dylib +extern void mach_init(void); // from libsystem_mach.dylib +extern void pthread_init(void); // from libc.a +extern void __libc_init(const struct ProgramVars *vars, void (*atfork_prepare)(void), void (*atfork_parent)(void), void (*atfork_child)(void), const char *apple[]); // from libc.a +extern void __keymgr_initializer(void); // from libkeymgr.a +extern void _dyld_initializer(void); // from libdyld.a +extern void libdispatch_init(void); // from libdispatch.a +extern void _libxpc_initializer(void); // from libxpc + +// system library atfork handlers +extern void _cthread_fork_prepare(); +extern void _cthread_fork_parent(); +extern void _cthread_fork_child(); +extern void _cthread_fork_child_postinit(); + +extern void _mach_fork_child(); +extern void _cproc_fork_child(); +extern void _libc_fork_child(); +extern void _notify_fork_child(); +extern void _dyld_fork_child(); +extern void xpc_atfork_prepare(); +extern void xpc_atfork_parent(); +extern void xpc_atfork_child(); + +// advance decls for below; +void libSystem_atfork_prepare(); +void libSystem_atfork_parent(); +void libSystem_atfork_child(); + +// from mig_support.c in libc +mach_port_t _mig_get_reply_port(); +void _mig_set_reply_port(mach_port_t); + +void cthread_set_errno_self(int); +int* __error(void); + +/* + * libsyscall_initializer() initializes all of libSystem.dylib + */ +static __attribute__((constructor)) +void libSystem_initializer(int argc, const char* argv[], const char* envp[], const char* apple[], const struct ProgramVars* vars) +{ + _libkernel_functions_t libkernel_funcs = { + .get_reply_port = _mig_get_reply_port, + .set_reply_port = _mig_set_reply_port, + .get_errno = __error, + .set_errno = cthread_set_errno_self, + .dlsym = dlsym, + }; + + _libkernel_init(libkernel_funcs); + + bootstrap_init(); + mach_init(); + pthread_init(); + __libc_init(vars, libSystem_atfork_prepare, libSystem_atfork_parent, libSystem_atfork_child, apple); + __keymgr_initializer(); + _dyld_initializer(); + libdispatch_init(); +#if !TARGET_OS_EMBEDDED || __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // __IPHONE_5_0 + _libxpc_initializer(); +#endif +} + +/* + * libSystem_atfork_{prepare,parent,child}() are called by libc when we fork, then we deal with running fork handlers + * for everyone else. + */ +void libSystem_atfork_prepare() +{ +#if !TARGET_OS_EMBEDDED || __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // __IPHONE_5_0 + xpc_atfork_prepare(); +#endif + _cthread_fork_prepare(); +} + +void libSystem_atfork_parent() +{ + _cthread_fork_parent(); +#if !TARGET_OS_EMBEDDED || __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // __IPHONE_5_0 + xpc_atfork_parent(); +#endif +} + +void libSystem_atfork_child() +{ + _dyld_fork_child(); + _cthread_fork_child(); + + bootstrap_init(); + _mach_fork_child(); + _cproc_fork_child(); + _libc_fork_child(); + _notify_fork_child(); +#if !TARGET_OS_EMBEDDED || __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // __IPHONE_5_0 + xpc_atfork_child(); +#endif + + _cthread_fork_child_postinit(); +} + +/* + * Old crt1.o glue used to call through mach_init_routine which was used to initialize libSystem. + * LibSystem now auto-initializes but mach_init_routine is left for binary compatibility. + */ +static void mach_init_old() {} +void (*mach_init_routine)(void) = &mach_init_old; + +/* + * This __crashreporter_info__ symbol is for all non-dylib parts of libSystem. + */ +const char *__crashreporter_info__; +asm (".desc __crashreporter_info__, 0x10"); + +#endif /* __DYNAMIC__ */ diff --git a/libsys/Makefile b/libsys/Makefile deleted file mode 100644 index 786c9c5..0000000 --- a/libsys/Makefile +++ /dev/null @@ -1,116 +0,0 @@ -NAME = libc - -.include -.include - -NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w -.ifdef ALTUSRLOCALLIBSYSTEM -LIBSYS = $(ALTUSRLOCALLIBSYSTEM) -.else -LIBSYS = $(SDKROOT)/usr/local/lib/system -.endif -NJOBS != $(PERL) -e '$$n = `$(SYSCTL) -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)' -BSDMAKEJ = $(BSDMAKE) -f Makefile -j $(NJOBS) - -# These variables are to guarantee that the left-hand side of an expression is -# always a variable -dynamic = dynamic - -FORMS := dynamic - -.if !empty(FEATURE_DEBUG_DYLIB) -FORMS += debug -.endif - -.if !empty(FEATURE_PROFILE_DYLIB) -FORMS += profile -.endif - -all: build - -build: build-debug build-dynamic build-profile - -# These are the non B&I defaults -.ifndef RC_ProjectName -install: installhdrs install-all - -.else # RC_ProjectName - -.for F in $(FORMS) -install: BI-install-$(F) -.endfor # FORMS -.endif # RC_ProjectName - -.for F in $(FORMS) -.if $(dynamic) == $(F) -SUFFIX$(F) = -.else -SUFFIX$(F) = _$(F) -.endif -LIPOARGS$(F) != $(PERL) -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).a\"), qw($(RC_ARCHS))))' - -.for A in $(RC_ARCHS) -build-$(F): build-$(A)-$(F) -.endfor # RC_ARCHS -build-$(F): -.if $(NARCHS) == 1 - $(CP) "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).a" "$(SYMROOT)" -.else - $(LIPO) -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" -.endif - $(RANLIB) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" - -.for A in $(RC_ARCHS) -build-$(A)-$(F): $(OBJROOT)/$(A)/libsystem.o - $(MKDIR) '$(OBJROOT)/$(A)/$(F)' - @set -x && \ - cd '$(OBJROOT)/$(A)/$(F)' && \ - if $(LIPO) -info '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' | $(GREP) -q '^Non-'; then \ - $(CP) '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' .; \ - else \ - arch=`$(LIPO) -detailed_info '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' | $(SED) -E -n 's/.*architecture:? //p' | $(SORT) | $(GREP) '^$(A)' | $(HEAD) -n 1` && \ - $(LIPO) -thin $$arch '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' -output '$(NAME)-partial$(SUFFIX$(F)).a'; \ - fi && \ - $(AR) x '$(NAME)-partial$(SUFFIX$(F)).a' && \ - if $(LIPO) -info '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' | $(GREP) -q '^Non-'; then \ - $(CP) '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' .; \ - else \ - arch=`$(LIPO) -detailed_info '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' | $(SED) -E -n 's/.*architecture:? //p' | $(SORT) | $(GREP) '^$(A)' | $(HEAD) -n 1` && \ - $(LIPO) -thin $$arch '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' -output 'libsyscall$(SUFFIX$(F)).a'; \ - fi && \ - $(AR) x 'libsyscall$(SUFFIX$(F)).a' && \ - NM=$(NM) '$(SRCROOT)/libsys/build-libc.pl' '$(LIBSYS)' '$(OBJROOT)/$(A)/$(F)' && \ - $(LN) -s ../libsystem.o && \ - $(BSDMAKEJ) -.endfor # RC_ARCHS -.endfor # FORMS - -.for A in $(RC_ARCHS) -$(OBJROOT)/$(A)/libsystem.o: $(OBJROOT)/libsystem.c - $(MKDIR) '$(OBJROOT)/$(A)' - $(CC) -c -o '$(.TARGET)' -arch $(A) '$(.ALLSRC)' -.endfor # RC_ARCHS - -$(OBJROOT)/libsystem.c: - $(SDKROOT)/Developer/Makefiles/bin/version.pl Libsystem > $(.TARGET) - -installhdrs: - -.for F in $(FORMS) -BI-install-$(F): build-$(F) - $(MKDIR) "$(DSTROOT)/usr/local/lib/system" - @$(ECHO) "===== Installing $(NAME)$(SUFFIX$(F)).a =====" - $(INSTALL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" "$(DSTROOT)/usr/local/lib/system" - $(RANLIB) "$(DSTROOT)/usr/local/lib/system/$(NAME)$(SUFFIX$(F)).a" - $(CHMOD) 0444 "$(DSTROOT)/usr/local/lib/system/$(NAME)$(SUFFIX$(F)).a" -.endfor # FORMS - -install-all: build -.for F in $(FORMS) -install-all: BI-install-$(F) -.endfor # FORMS - -clean: -.for A in $(RC_ARCHS) - $(RMDIR) $(OBJROOT)/$(A) -.endfor # RC_ARCHS diff --git a/libsys/build-libc.pl b/libsys/build-libc.pl deleted file mode 100755 index f74a030..0000000 --- a/libsys/build-libc.pl +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (c) 2006-2007, 2009 Apple Inc. All rights reserved. -# -# @APPLE_LICENSE_HEADER_START@ -# -# This file contains Original Code and/or Modifications of Original Code -# as defined in and that are subject to the Apple Public Source License -# Version 2.0 (the 'License'). You may not use this file except in -# compliance with the License. Please obtain a copy of the License at -# http://www.opensource.apple.com/apsl/ and read it before using this -# file. -# -# The Original Code and all software distributed under the License are -# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. -# Please see the License for the specific language governing rights and -# limitations under the License. -# -# @APPLE_LICENSE_HEADER_END@ -# -########################################################################## -# -# % build-libc.pl usr-local-lib-system out-directory -# -# This script takes the directory full of the contents libc-partial*.a and -# libsyscall*.a, and makes the necessary symbol aliases for those syscalls -# that aren't being wrapped in Libc. The usr-local-lib-system is the -# /usr/local/lib/system or equivalent directory where the necessary symbol -# files from Libc and Libsyscall reside. -# -# A Makefile is created that will build libc*.a from the contents of the -# out-directory after symbol aliasing has been added. -# -# The out-directory path must be of the form ".../arch/form", where arch is -# the architecture being built and form is one of debug, dynamic and profile. -# -########################################################################## - -use strict; -use DirHandle; -use File::Basename (); -use File::Copy (); -use File::Spec; -use IO::File; - -my $MyName = File::Basename::basename($0); - -my $OutDir; -my %Stub; -my %StubArgs; -my $StubFile = 'libsyscall.list'; -my %Suffix = ( - debug => ['do', '_debug'],, - dynamic => ['So', ''],, - profile => ['po', '_profile'],, -); -my $SyscallBase = 'libc.syscall'; - -########################################################################## -# Scan the archive for existing wrappers, and remove them from the stub -# list. -########################################################################## -sub processLibc { - my($arch, $dir) = @_; - local $_; - my $file = File::Spec->join($dir, 'libc-partial.a'); - my $f = IO::File->new("$ENV{NM} -g -arch $arch $file |"); - die "$MyName: $ENV{NM} -g -arch $arch $file: $!\n" unless defined($f); - while(<$f>) { - next unless s/^.* T //; - chomp; - delete($Stub{$_}); - } -} - -########################################################################## -# Read the libc.syscall and any libc.syscall.arch file for additional aliases -# for the double underbar syscalls. -########################################################################## -sub readLibcSyscalls { - my($arch, $dir) = @_; - local $_; - my @files = (File::Spec->join($dir, $SyscallBase)); - my $archfile = File::Spec->join($dir, "$SyscallBase.$arch"); - if(-r $archfile) { - push(@files, $archfile); - } elsif($arch =~ s/^armv.*/arm/) { - $archfile = File::Spec->join($dir, "$SyscallBase.$arch"); - push(@files, $archfile) if -r $archfile; - } - foreach my $file (@files) { - my $f = IO::File->new($file, 'r'); - die "$MyName: $file: $!\n" unless defined($f); - while(<$f>) { - next if /^#/; - chomp; - my($k, $v) = split; - if(defined($v)) { - $Stub{$k} = $v; - } else { - delete($Stub{$k}); - } - } - } -} - -########################################################################## -# Read the libsyscall.list file for the system call names and number -# of arguments and store in %StubArgs. Also, make an entry for a syscall -# stub. -########################################################################## -sub readStub { - my $dir = shift; - local $_; - my $file = File::Spec->join($dir, $StubFile); - my $f = IO::File->new($file, 'r'); - die "$MyName: $file: $!\n" unless defined($f); - while(<$f>) { - chomp; - my($k, $v) = split; - if(!($k =~ s/^#//)) { - $_ = $k; - s/^__//; - $Stub{$_} = $k; - } - $StubArgs{$k} = $v; - } -} - -sub usage { - die "Usage: $MyName usr-local-lib-system out-directory\n"; -} - -usage() unless scalar(@ARGV) == 2; -my($usr_local_lib_system); -($usr_local_lib_system, $OutDir) = @ARGV; -die "$MyName: $usr_local_lib_system: No such directory\n" unless -d $usr_local_lib_system; -die "$MyName: $OutDir: No such directory\n" unless -d $OutDir; -my @pieces = File::Spec->splitdir($OutDir); -my $form = pop(@pieces); -my $arch = pop(@pieces); -my $suf = $Suffix{$form}; -die "$MyName: $form: Unknown form\n" unless defined($suf); -my($suffix, $sufname) = @$suf; -readStub($usr_local_lib_system); -readLibcSyscalls($arch, $usr_local_lib_system); -processLibc($arch, $usr_local_lib_system); - -########################################################################## -# Invert the Stub hash, so the key will correspond to the file to process. -# The value will be an array ref containing all aliases. -########################################################################## -my %Inv; -while(my($k, $v) = each(%Stub)) { - my $a = $Inv{$v}; - $a = $Inv{$v} = [] if !defined($a); - push(@$a, $k); -} - -########################################################################## -# Create the Makefile file -########################################################################## -my $path = File::Spec->join($OutDir, 'Makefile'); -my $f = IO::File->new($path, 'w'); -die "$MyName: $path: $!\n" unless defined($f); -print $f ".include \n\n"; - -########################################################################## -# List all the object files -########################################################################## -my $dir = DirHandle->new($OutDir); -die "$MyName: can't open $dir\n" unless defined($dir); -print $f "OBJS = libsystem.o \\\n"; -my @objs; -while(defined($_ = $dir->read())) { - next unless s/\.$suffix$/.o/; - push(@objs, $_); -} -undef $dir; -printf $f "\t%s\n", join(" \\\n\t", @objs); - -########################################################################## -# Add the build logic -########################################################################## -print $f <