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

Switch to cdylibs #8

Open
geofft opened this issue Jun 5, 2018 · 2 comments
Open

Switch to cdylibs #8

geofft opened this issue Jun 5, 2018 · 2 comments

Comments

@geofft
Copy link
Owner

geofft commented Jun 5, 2018

This seems like the right thing to do (cf. Rust RFC 1510) but when I tried it it didn't export my hook function.

$ nm -D examples/readlinkspy/target/debug/libreadlinkspy.so
                 w __cxa_finalize
                 w __gmon_start__
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 w _Jv_RegisterClasses
00000000000009d0 T rust_eh_personality
                 U _Unwind_GetDataRelBase
                 U _Unwind_GetIPInfo
                 U _Unwind_GetLanguageSpecificData
                 U _Unwind_GetRegionStart
                 U _Unwind_GetTextRelBase
                 U _Unwind_SetGR
                 U _Unwind_SetIP
@milahu
Copy link

milahu commented Sep 28, 2021

it didn't export my hook function

same, but it works with LD_PRELOAD

symbol count, as reported by nm
3139 dylib
68 cdylib

@milahu
Copy link

milahu commented Sep 30, 2021

redhook + crate_type = ["cdylib"] requires rust-nightly

[lib]
crate_type = ["dylib"] # works with rust-stable and rust-nightly
# release binary size
# 2.7M rust-stable
# 5.2M rust-nightly
[lib]
crate_type = ["cdylib"] # requires rust-nightly. silently fails with rust-stable
# release binary size
# 450 KB rust-nightly
#  20 KB rust-stable (broken)

compile options for my project

[profile.release]
# https://arusahni.net/blog/2020/03/optimizing-rust-binary-size.html
# https://github.com/johnthagen/min-sized-rust
opt-level = "s" # optimize for binary size
lto = true
codegen-units = 1
panic = "abort" # disable backtraces on panic

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

No branches or pull requests

2 participants