summaryrefslogtreecommitdiffstats
path: root/content/browser/mac/closure_blocks_leopard_compat.S
blob: 88a63dad2a831c5016500f1b6c083d62f6597832 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Definitions of symbols that may be needed at runtime but aren't necessarily
# present in the SDK chosen for compilation.
#
# This file provides symbols for _NSConcreteGlobalBlock and
# _NSConcreteStackBlock, normally present in libSystem.dylib and provided by
# by libclosure-38/data.c in Mac OS X 10.6 and later. It also provides symbols
# for various block runtime functions provided by libclosure-38/runtime.c.
# When using the 10.5 SDK, the symbols are not present. This file's definition
# can be used with extreme care in an application that needs to use the 10.5
# SDK in conjunction with blocks.
#
# This file cooperates with the build system to produce a dynamic library
# that, when linked against, causes dependents to look in libSystem for the
# symbols provided here. It also cooperates with a header that causes
# dependents to treat the symbols provided here as weak imports, critical for
# the resultant output to be loadable on 10.5.

# To simplify things, this file assumes it's being built with the 10.5 SDK,
# a deployment target of 10.5, and is producing 32-bit x86 code. Other
# combinations are possible, but not interesting for the time being. See
# <sys/cdefs.h> for interesting ways that names might be mangled in other
# configurations.

#include <AvailabilityMacros.h>

#if MAC_OS_X_VERSION_MIN_REQUIRED != MAC_OS_X_VERSION_10_5 || \
    MAC_OS_X_VERSION_MAX_ALLOWED != MAC_OS_X_VERSION_10_5 || \
    !defined(__i386__)
#error This file only supports 32-bit x86 code with both SDK and DT set to 10.5
#endif

#define DEFINE_GLOBAL_SYMBOL(name) \
    .globl name ## ;\
    name ## :

.text

# Mac OS X 10.6.8 libclosure-38/runtime.c

DEFINE_GLOBAL_SYMBOL(__Block_copy)
DEFINE_GLOBAL_SYMBOL(__Block_release)
DEFINE_GLOBAL_SYMBOL(__Block_object_assign)
DEFINE_GLOBAL_SYMBOL(__Block_object_dispose)

.section __DATA,__data

# Mac OS X 10.6.8 libclosure-38/data.c

DEFINE_GLOBAL_SYMBOL(__NSConcreteGlobalBlock)
DEFINE_GLOBAL_SYMBOL(__NSConcreteStackBlock)

# When this file is in use, the linker is expected to link things against both
# this file and the real copy of libSystem present in the SDK. When doing so,
# the linker is smart enough to produce only one LC_LOAD_DYLIB load command.
# However, it's not smart enough to notice that while this file's dylib only
# provides weak-imported symbols, the real libSystem's dylib does not.
# Consequently, it may produce an LC_LOAD_WEAK_DYLIB load command for
# libSystem instead of an ordinary LC_LOAD_DYLIB command. LC_LOAD_WEAK_DYLIB
# declares that any symbol offered by the library, and in fact the entire
# library, is permitted to be missing at runtime. This is entirely
# inappropriate for libSystem. To counteract this problem, this file also
# defines some other symbols that libSystem provides. Dependents of this
# library are not expected to treat these other symbols as weak imports. In
# order for any dependent that links against this library to load it with an
# LC_LOAD_DYLIB command instead of an LC_LOAD_WEAK_DYLIB command, this library
# must satisfy at least one unresolved non-weak-import symbol required by the
# dependent.

.text

# |exit| is a good one: because it's referenced by crt1.o, ordinary executables
# are guaranteed to need this symbol. Unfortunately, there's no such symbol in
# dylib1.o that libSystem is expected to provide, so a few other common libc
# symbols are thrown into the mix.
DEFINE_GLOBAL_SYMBOL(_exit)

# Include |close| because well-written programs that use the standard library
# are likely to refer to it. Include |open| for good measure because it goes
# pretty well with this. Include the stdio abstractions for these functions
# as well.
DEFINE_GLOBAL_SYMBOL(_close$UNIX2003)
DEFINE_GLOBAL_SYMBOL(_open$UNIX2003)
DEFINE_GLOBAL_SYMBOL(_fclose)
DEFINE_GLOBAL_SYMBOL(_fopen)
DEFINE_GLOBAL_SYMBOL(_fdopen)
DEFINE_GLOBAL_SYMBOL(_freopen$UNIX2003)

# Commonly-used allocation functions.
DEFINE_GLOBAL_SYMBOL(_malloc)
DEFINE_GLOBAL_SYMBOL(_calloc)
DEFINE_GLOBAL_SYMBOL(_realloc)
DEFINE_GLOBAL_SYMBOL(_reallocf)
DEFINE_GLOBAL_SYMBOL(_valloc)
DEFINE_GLOBAL_SYMBOL(_free)

# Include |printf|, |fprintf|, |sprintf|, |snprintf|, and |puts|, because
# small test programs are likely to refer to one of these. puts is rarely
# invoked directly, but the compiler may optimize simple printf calls into
# puts calls.
DEFINE_GLOBAL_SYMBOL(_printf)
DEFINE_GLOBAL_SYMBOL(_fprintf)
DEFINE_GLOBAL_SYMBOL(_sprintf)
DEFINE_GLOBAL_SYMBOL(_snprintf)
DEFINE_GLOBAL_SYMBOL(_puts)

# Some <string.h> functions that are commonly used.
DEFINE_GLOBAL_SYMBOL(_memcmp)
DEFINE_GLOBAL_SYMBOL(_memcpy)
DEFINE_GLOBAL_SYMBOL(_memmove)
DEFINE_GLOBAL_SYMBOL(_memset)
DEFINE_GLOBAL_SYMBOL(_strcasecmp)
DEFINE_GLOBAL_SYMBOL(_strcat)
DEFINE_GLOBAL_SYMBOL(_strchr)
DEFINE_GLOBAL_SYMBOL(_strcmp)
DEFINE_GLOBAL_SYMBOL(_strcpy)
DEFINE_GLOBAL_SYMBOL(_strdup)
DEFINE_GLOBAL_SYMBOL(_strlcat)
DEFINE_GLOBAL_SYMBOL(_strlcpy)
DEFINE_GLOBAL_SYMBOL(_strlen)
DEFINE_GLOBAL_SYMBOL(_strncasecmp)
DEFINE_GLOBAL_SYMBOL(_strncat)
DEFINE_GLOBAL_SYMBOL(_strncmp)
DEFINE_GLOBAL_SYMBOL(_strncpy)
DEFINE_GLOBAL_SYMBOL(_strnstr)
DEFINE_GLOBAL_SYMBOL(_strstr)

# Some data-section symbols that might be referenced.

.section __DATA,__data

DEFINE_GLOBAL_SYMBOL(___stdinp)
DEFINE_GLOBAL_SYMBOL(___stdoutp)
DEFINE_GLOBAL_SYMBOL(___stderrp)

#undef DEFINE_GLOBAL_SYMBOL