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