Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable semantic interposition in ELF shared libraries #821

Merged
merged 1 commit into from Jan 11, 2021

Conversation

Dead2
Copy link
Member

@Dead2 Dead2 commented Jan 11, 2021

Disallow semantic interposition in ELF shared libraries if supported by the compiler.
This disallows calls to our own exported functions being replaced by LD_PRELOAD, thus
avoiding the potential bugs and allowing the compiler to optimize better.

The best/most detailed description of this compiler parameter I have found is here:
https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup

I have not been able to reliably measure a performance difference with this, and that is
likely because we rarely call our own exported functions, and never in any hot areas.

This does give a little size reduction for the shared library.

Configure before
   text    data     bss     dec     hex filename
 106832    1368      32  108232   1a6c8 libz-ng.so.1.9.9

Configure with PR
   text    data     bss     dec     hex filename
 106504    1296      32  107832   1a538 libz-ng.so.1.9.9
Cmake before
   text    data     bss     dec     hex filename
 111456    1368      32  112856   1b8d8 libz-ng.so.1.9.9

Cmake with PR
   text    data     bss     dec     hex filename
 111064    1296      32  112392   1b708 libz-ng.so.1.9.9

@codecov
Copy link

codecov bot commented Jan 11, 2021

Codecov Report

Merging #821 (5326715) into develop (446c697) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #821   +/-   ##
========================================
  Coverage    76.67%   76.67%           
========================================
  Files           71       71           
  Lines         7457     7457           
  Branches      1341     1342    +1     
========================================
  Hits          5718     5718           
+ Misses        1211     1210    -1     
- Partials       528      529    +1     
Flag Coverage Δ
macos_clang 68.60% <ø> (ø)
macos_gcc 67.78% <ø> (ø)
ubuntu_clang 74.93% <ø> (ø)
ubuntu_clang_inflate_allow_invalid_dist 74.85% <ø> (ø)
ubuntu_clang_inflate_strict 75.12% <ø> (ø)
ubuntu_clang_mmap 74.88% <ø> (ø)
ubuntu_clang_msan 74.92% <ø> (ø)
ubuntu_gcc 77.43% <ø> (ø)
ubuntu_gcc_aarch64 76.91% <ø> (ø)
ubuntu_gcc_aarch64_compat_no_opt 74.66% <ø> (ø)
ubuntu_gcc_aarch64_no_acle 75.99% <ø> (ø)
ubuntu_gcc_aarch64_no_neon 75.73% <ø> (ø)
ubuntu_gcc_armhf 77.41% <ø> (ø)
ubuntu_gcc_armhf_compat_no_opt 74.67% <ø> (ø)
ubuntu_gcc_armhf_no_acle 76.42% <ø> (ø)
ubuntu_gcc_armhf_no_neon 76.79% <ø> (ø)
ubuntu_gcc_armsf 77.41% <ø> (ø)
ubuntu_gcc_armsf_compat_no_opt 74.67% <ø> (ø)
ubuntu_gcc_compat_no_opt 75.18% <ø> (ø)
ubuntu_gcc_mingw_x86_64 75.65% <ø> (+0.04%) ⬆️
ubuntu_gcc_no_avx2 76.72% <ø> (ø)
ubuntu_gcc_no_pclmulqdq 75.10% <ø> (ø)
ubuntu_gcc_no_sse2 75.99% <ø> (ø)
ubuntu_gcc_no_sse4 75.11% <ø> (ø)
ubuntu_gcc_o3 75.77% <ø> (ø)
ubuntu_gcc_osb 76.51% <ø> (ø)
ubuntu_gcc_ppc 77.59% <ø> (ø)
ubuntu_gcc_ppc64 76.82% <ø> (ø)
ubuntu_gcc_ppc64le 76.02% <ø> (ø)
ubuntu_gcc_s390x 75.18% <ø> (ø)
ubuntu_gcc_sparc64 78.06% <ø> (+0.96%) ⬆️
win64_gcc 73.11% <ø> (ø)
win64_gcc_compat_no_opt 74.63% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gzlib.c 54.51% <0.00%> (-0.38%) ⬇️
trees.c 95.79% <0.00%> (-0.33%) ⬇️
inffast.c 90.37% <0.00%> (+1.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 446c697...5326715. Read the comment docs.

Copy link
Member

@nmoinvaz nmoinvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only had minor questions, otherwise looks good!

configure Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
…by the compiler.

This disallows calls to our own exported functions being replaced by LD_PRELOAD, thus
avoiding the potential bugs and allowing the compiler to optimize better.
Copy link
Member

@nmoinvaz nmoinvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dead2 Dead2 merged commit 1f5890d into develop Jan 11, 2021
@Dead2 Dead2 deleted the semantic-interposition branch January 29, 2021 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants