Skip to content

Commit

Permalink
Do not include '@' in symbol name
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 authored and VitalyAnkh committed Dec 23, 2023
1 parent f703459 commit b17f5db
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
5 changes: 3 additions & 2 deletions elf/input-files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ Symbol<E> *get_symbol(Context<E> &ctx, std::string_view key,
}

template <typename E>
Symbol<E> *get_symbol(Context<E> &ctx, std::string_view name) {
return get_symbol(ctx, name, name);
Symbol<E> *get_symbol(Context<E> &ctx, std::string_view key) {
std::string_view name = key.substr(0, key.find('@'));
return get_symbol(ctx, key, name);
}

template <typename E>
Expand Down
30 changes: 30 additions & 0 deletions test/elf/trace-symbol-symver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
. $(dirname $0)/common.inc

cat <<EOF | $CC -c -o $t/a.o -xc -
void foo1() {}
void foo2() {}
void foo3() {}
__asm__(".symver foo1, foo@VER1");
__asm__(".symver foo2, foo@VER2");
__asm__(".symver foo3, foo@@VER3");
EOF

cat <<EOF > $t/b.version
VER1 { local: *; };
VER2 { local: *; };
VER3 { local: *; };
EOF

$CC -B. -o $t/c.so -shared $t/a.o -Wl,--version-script=$t/b.version \
-Wl,--trace-symbol='foo@VER1' > /dev/null

cat <<EOF | $CC -c -o $t/d.o -xc -
void foo();
__asm__(".symver foo, foo@VER1");
int main() { foo(); }
EOF

$CC -B. -o $t/exe $t/d.o $t/c.so -Wl,--trace-symbol='foo@VER1' > /dev/null
$QEMU $t/exe

0 comments on commit b17f5db

Please sign in to comment.