From: Fangrui Song <i@maskray.me>
To: binutils@sourceware.org
Cc: harald@gigawatt.nl
Subject: foo (VER_NDX_GLOBAL) and foo@@v1 in one DSO
Date: Thu, 10 Nov 2022 19:27:40 -0800 [thread overview]
Message-ID: <20221111032740.edekvhgrceu6frws@gmail.com> (raw)
Hello, I find a strange use of VER_NDX_GLOBAL and look forward to your thoughts.
cat > a.s <<e
.globl foo
.symver foo, foo@@@v1
foo:
nop
ret
.globl foo_compat
.symver foo_compat, foo@, remove
foo_compat:
ret
e
cat > a.ver <<e
v1 {};
e
cat > b.c <<e
extern void foo(void);
int main(void) { foo(); }
e
gcc -fuse-ld=bfd -shared -nostdlib -Wl,--version-script=a.ver a.s -o a.so
gcc -fuse-ld=bfd -g b.c ./a.so -o b
exit
In a.so, we have a default version foo@@v1 as well as a VER_NDX_GLOBAL foo.
The VER_NDX_GLOBAL foo is unusual.
```
% readelf -W --dyn-s -V a.so
Symbol table '.dynsym' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000001000 0 NOTYPE GLOBAL DEFAULT 7 foo@@v1
2: 0000000000001002 0 NOTYPE GLOBAL DEFAULT 7 foo
3: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS v1
Version symbols section '.gnu.version' contains 4 entries:
Addr: 0x000000000000028e Offset: 0x00028e Link: 3 (.dynsym)
000: 0 (*local*) 2 (v1) 1h 2 (v1)
Version definition section '.gnu.version_d' contains 2 entries:
Addr: 0x0000000000000298 Offset: 0x000298 Link: 4 (.dynstr)
000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: a.so
0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: v1
```
There are two strange things:
* foo is a VER_NDX_GLOBAL VERSYM_HIDDEN symbol (shown as `1h`). Is this an expected use case?
* foo co-exist with foo@@v1. Is this an expected use case?
In my understanding, when a stem symbol has a @ form, the unversioned VER_NDX_GLOBAL form cannot exist.
In the example above, `.symver foo_compat, foo@v0, remove` would be fine.
The above is reduced from a real world case of https://github.com/libfuse/libfuse/blob/fuse_2_9_bugfix/lib/fuse.c#L4955
`FUSE_SYMVER(".symver fuse_new_compat2,fuse_new@");`
% readelf -W --dyn-s /lib/x86_64-linux-gnu/libfuse.so.2 G fuse_new
200: 00000000000148b0 72 FUNC GLOBAL DEFAULT 13 fuse_new@FUSE_2.5
201: 0000000000014870 16 FUNC GLOBAL DEFAULT 13 fuse_new # this is VERSYM_HIDDEN
202: 0000000000014750 8 FUNC GLOBAL DEFAULT 13 fuse_new@@FUSE_2.6
203: 0000000000014860 11 FUNC GLOBAL DEFAULT 13 fuse_new@FUSE_2.2
216: 0000000000014880 35 FUNC GLOBAL DEFAULT 13 fuse_new_compat1@@FUSE_2.2
218: 0000000000014870 16 FUNC GLOBAL DEFAULT 13 fuse_new_compat2@@FUSE_2.2
228: 0000000000014860 11 FUNC GLOBAL DEFAULT 13 fuse_new_compat22@@FUSE_2.5
230: 00000000000148b0 72 FUNC GLOBAL DEFAULT 13 fuse_new_compat25@@FUSE_2.6
next reply other threads:[~2022-11-11 3:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 3:27 Fangrui Song [this message]
2023-04-18 4:52 ` Fangrui Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111032740.edekvhgrceu6frws@gmail.com \
--to=i@maskray.me \
--cc=binutils@sourceware.org \
--cc=harald@gigawatt.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).