diff options
author | Alexander Miller <alex.miller@gmx.de> | 2022-12-22 05:21:30 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2023-02-13 09:40:57 +0100 |
commit | 11b9069098b4d4c23efb06c9457a085b784354d4 (patch) | |
tree | 4e2a9d053306cd0e30d381f8b834e41f43a6f932 /libattr/libattr.lds | |
parent | 0981a7bfe4871191c107fa1679cb9eeabf603f33 (diff) | |
download | attr-11b9069098b4d4c23efb06c9457a085b784354d4.tar.gz |
libattr: Set symbol versions for legacy syscalls via attribute or asm
Currently, a linker script is used to define versioned symbols
for the legacy linux syscalls with simple assignments.
That isn't mentioned in ld's documentation as a valid method to
set symbol versions, and while one might assume that it should work
and the linker script is accepted, the result often isn't correct:
gold and lld always create broken binaries, and even the bfd linker
can create unusable symbols if used with --gc-sections or LTO.
For example, the result can be a library where the function has been
discarded and the versioned symbol is unusable, i.e.,
23: 00000000 0 NOTYPE GLOBAL DEFAULT ABS getxattr@ATTR_1.0
instead of
23: 000033c0 0 FUNC GLOBAL DEFAULT 11 getxattr@ATTR_1.0
Meanwhile, lld doubles the version suffix: getxattr@ATTR_1.0@ATTR_1.0
Not that these issues may be viewed as linker bugs, and there may
or may not be some related improvements to linker script handling
since I tested this a few months ago (binutils-2.37, lld-14).
But in either case a more robust solution would be preferable.
So remove the linker script entirely and set symbol versions with
__attribute__((__symver__(...))) if available (i.e., in gcc >= 10,
but not in clang). Otherwise use the traditional global asm solution
with a .symver directive. These are the well documented methods (along
with version scripts, which don't apply here) to set symbol versions
and work correctly with all linkers, including older versions.
A workaround that is needed for gcc < 10 not to break LTO partitioning
with global asm is also included (__attribute__((__no_reorder__))),
but some very old versions may still need -flto-partition=none to build
correctly with LTO (not going to bother with completely obsolete versions).
Signed-off-by: Alexander Miller <alex.miller@gmx.de>
Diffstat (limited to 'libattr/libattr.lds')
-rw-r--r-- | libattr/libattr.lds | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/libattr/libattr.lds b/libattr/libattr.lds deleted file mode 100644 index 947f15d..0000000 --- a/libattr/libattr.lds +++ /dev/null @@ -1,12 +0,0 @@ -"fgetxattr@ATTR_1.0" = libattr_fgetxattr; -"flistxattr@ATTR_1.0" = libattr_flistxattr; -"fremovexattr@ATTR_1.0" = libattr_fremovexattr; -"fsetxattr@ATTR_1.0" = libattr_fsetxattr; -"getxattr@ATTR_1.0" = libattr_getxattr; -"lgetxattr@ATTR_1.0" = libattr_lgetxattr; -"listxattr@ATTR_1.0" = libattr_listxattr; -"llistxattr@ATTR_1.0" = libattr_llistxattr; -"lremovexattr@ATTR_1.0" = libattr_lremovexattr; -"lsetxattr@ATTR_1.0" = libattr_lsetxattr; -"removexattr@ATTR_1.0" = libattr_removexattr; -"setxattr@ATTR_1.0" = libattr_setxattr; |