Skip to content

Commit

Permalink
Allow escaped meta-characters in version script patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Dec 24, 2023
1 parent 669ada0 commit 9554b92
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/glob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
15 changes: 15 additions & 0 deletions test/elf/version-script23.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9554b92

Please sign in to comment.