xz-analysis-mirror/src
Lasse Collin a2f5ca706a liblzma: #define lzma_attr_visibility_hidden in common.h.
In ELF shared libs:

-fvisibility=hidden affects definitions of symbols but not
declarations.[*] This doesn't affect direct calls to functions
inside liblzma as a linker can replace a call to lzma_foo@plt
with a call directly to lzma_foo when -fvisibility=hidden is used.

[*] It has to be like this because otherwise every installed
    header file would need to explictly set the symbol visibility
    to default.

When accessing extern variables that aren't defined in the
same translation unit, compiler assumes that the variable has
the default visibility and thus indirection is needed. Unlike
function calls, linker cannot optimize this.

Using __attribute__((__visibility__("hidden"))) with the extern
variable declarations tells the compiler that indirection isn't
needed because the definition is in the same shared library.

About 15+ years ago, someone told me that it would be good if
the CRC tables would be defined in the same translation unit
as the C code of the CRC functions. While I understood that it
could help a tiny amount, I didn't want to change the code because
a separate translation unit for the CRC tables was needed for the
x86 assembly code anyway. But when visibility attributes are
supported, simply marking the extern declaration with the
hidden attribute will get identical result. When there are only
a few affected variables, this is trivial to do. I wish I had
understood this back then already.
2023-10-30 18:03:39 +02:00
..
common mythread.h: Make MYTHREAD_POSIX compatible with MinGW-w64's winpthreads. 2023-10-22 18:59:45 +03:00
liblzma liblzma: #define lzma_attr_visibility_hidden in common.h. 2023-10-30 18:03:39 +02:00
lzmainfo xz, xzdec, lzmainfo: Use tuklib_attr_noreturn. 2023-09-22 20:06:27 +03:00
scripts Scripts: Change quoting style from `...' to '...'. 2023-09-24 22:10:41 +08:00
xz xz: Support basic sandboxing with Linux Landlock (ABI versions 1-3). 2023-10-22 19:03:52 +03:00
xzdec xz, xzdec, lzmainfo: Use tuklib_attr_noreturn. 2023-09-22 20:06:27 +03:00
Makefile.am Build: Prepare to support Automake's subdir-objects. 2014-10-29 21:15:35 +02:00