OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 # Definitions of symbols that may be needed at runtime but aren't necessarily |
| 6 # present in the SDK chosen for compilation. |
| 7 # |
| 8 # This file provides a symbols for _NSConcreteGlobalBlock and |
| 9 # _NSConcreteStackBlock, normally present in libSystem.dylib and provided by |
| 10 # by libclosure-38/data.c in Mac OS X 10.6 and later. When using the 10.5 SDK, |
| 11 # the symbol is not present. This file's definition can be used with extreme |
| 12 # care in an application that needs to use the 10.5 SDK in conjunction with |
| 13 # blocks. |
| 14 # |
| 15 # This file cooperates with the build system (closure_leopard_compat.gyp) to |
| 16 # produce a dynamic library that, when linked against, causes dependents to |
| 17 # look in libSystem for the symbols provided here. It also cooperates with a |
| 18 # header (block.h) that causes dependents to treat the symbols provided here |
| 19 # as weak imports, critical for the resultant output to be loadable on 10.5. |
| 20 |
| 21 # To simplify things, this file assumes it's being built with the 10.5 SDK, |
| 22 # a deployment target of 10.5, and is producing 32-bit x86 code. Other |
| 23 # combinations are possible, but not interesting for the time being. See |
| 24 # <sys/cdefs.h> for interesting ways that names might be mangled in other |
| 25 # configurations. |
| 26 |
| 27 #include <AvailabilityMacros.h> |
| 28 |
| 29 #if MAC_OS_X_VERSION_MIN_REQUIRED != MAC_OS_X_VERSION_10_5 || \ |
| 30 MAC_OS_X_VERSION_MAX_ALLOWED != MAC_OS_X_VERSION_10_5 || \ |
| 31 !defined(__i386__) |
| 32 #error This file only supports 32-bit x86 code with both SDK and DT set to 10.5 |
| 33 #endif |
| 34 |
| 35 #define DEFINE_GLOBAL_SYMBOL(name) \ |
| 36 .globl name ## ;\ |
| 37 name ## : |
| 38 |
| 39 .section __DATA,__data |
| 40 |
| 41 DEFINE_GLOBAL_SYMBOL(__NSConcreteGlobalBlock) |
| 42 DEFINE_GLOBAL_SYMBOL(__NSConcreteStackBlock) |
| 43 |
| 44 # When this file is in use, the linker is expected to link things against both |
| 45 # this file and the real copy of libSystem present in the SDK. When doing so, |
| 46 # the linker is smart enough to produce only one LC_LOAD_DYLIB load command. |
| 47 # However, it's not smart enough to notice that while this file's dylib only |
| 48 # provides weak-imported symbols, the real libSystem's dylib does not. |
| 49 # Consequently, it may produce an LC_LOAD_WEAK_DYLIB load command for |
| 50 # libSystem instead of an ordinary LC_LOAD_DYLIB command. LC_LOAD_WEAK_DYLIB |
| 51 # declares that any symbol offered by the library, and in fact the entire |
| 52 # library, is permitted to be missing at runtime. This is entirely |
| 53 # inappropriate for libSystem. To counteract this problem, this file also |
| 54 # defines some other symbols that libSystem provides. Dependents of this |
| 55 # library are not expected to treat these other symbols as weak imports. In |
| 56 # order for any dependent that links against this library to load it with an |
| 57 # LC_LOAD_DYLIB command instead of an LC_LOAD_WEAK_DYLIB command, this library |
| 58 # must satisfy at least one unresolved non-weak-import symbol required by the |
| 59 # dependent. |
| 60 |
| 61 .text |
| 62 |
| 63 # |exit| is a good one: because it's referenced by crt1.o, ordinary executables |
| 64 # are guaranteed to need this symbol. Unfortunately, there's no such symbol in |
| 65 # dylib1.o that libSystem is expected to provide, so a few other common libc |
| 66 # symbols are thrown into the mix. |
| 67 DEFINE_GLOBAL_SYMBOL(_exit) |
| 68 |
| 69 # Include |close| because well-written programs that use the standard library |
| 70 # are likely to refer to it. Include |open| for good measure because it goes |
| 71 # pretty well with this. Include the stdio abstractions for these functions |
| 72 # as well. |
| 73 DEFINE_GLOBAL_SYMBOL(_close$UNIX2003) |
| 74 DEFINE_GLOBAL_SYMBOL(_open$UNIX2003) |
| 75 DEFINE_GLOBAL_SYMBOL(_fclose) |
| 76 DEFINE_GLOBAL_SYMBOL(_fopen) |
| 77 DEFINE_GLOBAL_SYMBOL(_fdopen) |
| 78 DEFINE_GLOBAL_SYMBOL(_freopen$UNIX2003) |
| 79 |
| 80 # Commonly-used allocation functions. |
| 81 DEFINE_GLOBAL_SYMBOL(_malloc) |
| 82 DEFINE_GLOBAL_SYMBOL(_calloc) |
| 83 DEFINE_GLOBAL_SYMBOL(_realloc) |
| 84 DEFINE_GLOBAL_SYMBOL(_reallocf) |
| 85 DEFINE_GLOBAL_SYMBOL(_valloc) |
| 86 DEFINE_GLOBAL_SYMBOL(_free) |
| 87 |
| 88 # Include |printf|, |fprintf|, |sprintf|, |snprintf|, and |puts|, because |
| 89 # small test programs are likely to refer to one of these. puts is rarely |
| 90 # invoked directly, but the compiler may optimize simple printf calls into |
| 91 # puts calls. |
| 92 DEFINE_GLOBAL_SYMBOL(_printf) |
| 93 DEFINE_GLOBAL_SYMBOL(_fprintf) |
| 94 DEFINE_GLOBAL_SYMBOL(_sprintf) |
| 95 DEFINE_GLOBAL_SYMBOL(_snprintf) |
| 96 DEFINE_GLOBAL_SYMBOL(_puts) |
| 97 |
| 98 # Some <string.h> functions that are commonly used. |
| 99 DEFINE_GLOBAL_SYMBOL(_memcmp) |
| 100 DEFINE_GLOBAL_SYMBOL(_memcpy) |
| 101 DEFINE_GLOBAL_SYMBOL(_memmove) |
| 102 DEFINE_GLOBAL_SYMBOL(_memset) |
| 103 DEFINE_GLOBAL_SYMBOL(_strcasecmp) |
| 104 DEFINE_GLOBAL_SYMBOL(_strcat) |
| 105 DEFINE_GLOBAL_SYMBOL(_strchr) |
| 106 DEFINE_GLOBAL_SYMBOL(_strcmp) |
| 107 DEFINE_GLOBAL_SYMBOL(_strcpy) |
| 108 DEFINE_GLOBAL_SYMBOL(_strdup) |
| 109 DEFINE_GLOBAL_SYMBOL(_strlcat) |
| 110 DEFINE_GLOBAL_SYMBOL(_strlcpy) |
| 111 DEFINE_GLOBAL_SYMBOL(_strlen) |
| 112 DEFINE_GLOBAL_SYMBOL(_strncasecmp) |
| 113 DEFINE_GLOBAL_SYMBOL(_strncat) |
| 114 DEFINE_GLOBAL_SYMBOL(_strncmp) |
| 115 DEFINE_GLOBAL_SYMBOL(_strncpy) |
| 116 DEFINE_GLOBAL_SYMBOL(_strnstr) |
| 117 DEFINE_GLOBAL_SYMBOL(_strstr) |
| 118 |
| 119 # Some data-section symbols that might be referenced. |
| 120 |
| 121 .section __DATA,__data |
| 122 |
| 123 DEFINE_GLOBAL_SYMBOL(___stdinp) |
| 124 DEFINE_GLOBAL_SYMBOL(___stdoutp) |
| 125 DEFINE_GLOBAL_SYMBOL(___stderrp) |
| 126 |
| 127 #undef DEFINE_GLOBAL_SYMBOL |
OLD | NEW |