1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-26 13:10:46 +03:00

Allow escaped meta-characters in version script patterns

This commit is contained in:
Rui Ueyama 2023-12-24 14:04:46 +09:00
parent 669ada024e
commit 9554b92c86
2 changed files with 23 additions and 0 deletions

View File

@ -79,6 +79,14 @@ std::optional<Glob> Glob::compile(std::string_view pat) {
case '*':
vec.push_back({STAR});
break;
case '\\':
if (pat.empty())
return {};
if (vec.empty() || vec.back().kind != STRING)
vec.push_back({STRING});
vec.back().str += pat[0];
pat = pat.substr(1);
break;
default:
if (vec.empty() || vec.back().kind != STRING)
vec.push_back({STRING});

15
test/elf/version-script23.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
. $(dirname $0)/common.inc
cat <<'EOF' > $t/a.ver
VER1 { foo\?; };
EOF
cat <<EOF | $CC -c -o $t/b.o -xassembler -
.globl "foo?"
"foo?":
EOF
$CC -B. -shared -Wl,--version-script=$t/a.ver -o $t/c.so $t/b.o
readelf -W --dyn-syms $t/c.so > $t/log
grep -Fq 'foo?@@VER1' $t/log