mirror of
https://github.com/rui314/mold.git
synced 2024-10-04 16:48:04 +03:00
[Mach-O] Handle $ld$add$ symbols
This commit is contained in:
parent
3af44d08db
commit
e11e68d508
@ -145,6 +145,17 @@ static void interpret_ld_symbols(Context<E> &ctx, TextDylib &tbd) {
|
||||
ctx.arg.platform_min_version < max_version) {
|
||||
tbd.install_name = save_string(ctx, install_name);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// $ld$add$os_version$symbol adds a symbol if the given OS version
|
||||
// matches.
|
||||
static std::regex re_add(R"(\$ld\$add\$os([\d.]+)\$(.+))", flags);
|
||||
|
||||
if (std::regex_match(name, m, re_add)) {
|
||||
if (ctx.arg.platform_min_version == parse_version(m[1]))
|
||||
tbd.exports.push_back(save_string(ctx, m[2]));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
45
test/macho/tbd-add.sh
Executable file
45
test/macho/tbd-add.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
export LC_ALL=C
|
||||
set -e
|
||||
CC="${TEST_CC:-cc}"
|
||||
CXX="${TEST_CXX:-c++}"
|
||||
GCC="${TEST_GCC:-gcc}"
|
||||
GXX="${TEST_GXX:-g++}"
|
||||
OBJDUMP="${OBJDUMP:-objdump}"
|
||||
MACHINE="${MACHINE:-$(uname -m)}"
|
||||
testname=$(basename "$0" .sh)
|
||||
echo -n "Testing $testname ... "
|
||||
cd "$(dirname "$0")"/../..
|
||||
t=out/test/macho/$testname
|
||||
mkdir -p $t
|
||||
|
||||
cat > $t/libfoo.tbd <<'EOF'
|
||||
--- !tapi-tbd
|
||||
tbd-version: 4
|
||||
targets: [ x86_64-macos, arm64-macos ]
|
||||
uuids:
|
||||
- target: x86_64-macos
|
||||
value: 00000000-0000-0000-0000-000000000000
|
||||
- target: arm64-macos
|
||||
value: 00000000-0000-0000-0000-000000000000
|
||||
install-name: '/foo'
|
||||
current-version: 0
|
||||
compatibility-version: 0
|
||||
exports:
|
||||
- targets: [ x86_64-macos, arm64-macos ]
|
||||
symbols: [ '$ld$add$os14.0$_foo' ]
|
||||
...
|
||||
EOF
|
||||
|
||||
cat <<EOF | clang -o $t/a.o -c -xc -
|
||||
void foo();
|
||||
void bar() { foo(); }
|
||||
EOF
|
||||
|
||||
! clang --ld-path=./ld64 -shared -o $t/b.dylib $t/libfoo.tbd $t/a.o \
|
||||
-Wl,-platform_version,macos,9.0,9.0 >& /dev/null || false
|
||||
|
||||
clang --ld-path=./ld64 -shared -o $t/b.dylib $t/libfoo.tbd $t/a.o \
|
||||
-Wl,-platform_version,macos,14.0,13.0 >& /dev/null
|
||||
|
||||
echo OK
|
Loading…
Reference in New Issue
Block a user