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

Unable to hide symbols of a shared library #2

Open
amontoison opened this issue Apr 17, 2023 · 4 comments
Open

Unable to hide symbols of a shared library #2

amontoison opened this issue Apr 17, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@amontoison
Copy link

Hi @yugr!

I try to use your tool SymbolHider to hide some symbols of a shared library.
I would like to link a package with libblastrampoline for the BLAS/LAPACK symbols and libmkl_rt for the MKL Pardiso solver.
The issue is that libmkl_rt also exports BLAS and LAPACK symbols.
I would like to use your tool to hide symbols not related to pardiso in libmkl_rt but it seems that nothing is updated.

nm -D libmkl_rt.so.2
...
00000000006acb00 T ZUPMTR
00000000006acb00 T zupmtr
00000000006acb00 T zupmtr_
00000000006acbb0 T ZUPMTR_64
00000000006acbb0 T zupmtr_64
00000000006acbb0 T zupmtr_64_
./sym-hider -v --hide libmkl_rt.so.2 zupmtr_64_
...
00000000006acb00 T ZUPMTR
00000000006acb00 T zupmtr
00000000006acb00 T zupmtr_
00000000006acbb0 T ZUPMTR_64
00000000006acbb0 T zupmtr_64
00000000006acbb0 T zupmtr_64_

libmkl_rt.so can be downloaded from https://anaconda.org/intel/mkl/files.

@yugr yugr self-assigned this Apr 18, 2023
@yugr yugr added the bug Something isn't working label Apr 18, 2023
@yugr
Copy link
Owner

yugr commented Apr 18, 2023

Thank you for the report, let me take a look at this within couple of days.

@yugr
Copy link
Owner

yugr commented Apr 18, 2023

Actually I think nm is imprecise here. readelf shows that symbol is indeed hidden:

$ readelf --dyn-syms -W libmkl_rt.so.2 | grep '\<zupmtr_64_\>'
 45616: 00000000006acbb0   176 FUNC    GLOBAL DEFAULT   13 zupmtr_64_
$ ~/src/SymbolHider/bin/sym-hider libmkl_rt.so.2 zupmtr_64_
$ readelf --dyn-syms -W libmkl_rt.so.2 | grep '\<zupmtr_64_\>'
 45616: 00000000006acbb0   176 FUNC    GLOBAL HIDDEN    13 zupmtr_64_

@amontoison
Copy link
Author

amontoison commented Apr 18, 2023

Great, it's exactly what I need!

I plan to use it in the cross-compiler BinaryBuilder.jl.
Is it working if the shared library libmkl_rt.so and sym-hider are compiled on different platforms?

I will compile SymbolHider on the host (x86_64-linux-musl) and use it to hide the symbols of the shared library of
the following platforms:

  • x86_64-apple-darwin
  • x86_64-linux-gnu
  • x86_64-w64-mingw32

I suppose that the support of 32-bit ELFs is needed for the platforms:

  • i686-linux-gnu
  • i686-w64-mingw32

But it's already great if I can use it for the 3 main 64-bits platforms.

@yugr
Copy link
Owner

yugr commented Apr 18, 2023

I plan to use it in the cross-compiler BinaryBuilder.jl. Is it working if the shared library libmkl_rt.so and sym-hider are compiled on different platforms?

It should although TBH I haven't tested it. I'll be around for bugs if any.

x86_64-apple-darwin
x86_64-w64-mingw32

These might be a problem - unfortunately they use different object file formats (Mach-O and PE) whereas SymbolHider only supports ELFs at the moment (I should make it clear in README). I can't say right now whether it's possible to modify symbol table for linked executables on these platforms.

I suppose that the support of 32-bit ELFs is needed for the platforms:
* i686-linux-gnu
* i686-w64-mingw32

This can be added if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants