Strip extern function symbols?

So I made a C script that defines a function for lets say it prints "hello" called hello()

And I link that C source file to my rust program using cc

finally i invoke the function after placing extern "C" somewhere in the script

the problem is, is that, no matter what rustc flag, cargo parameter, strip all, option i pass, i can't seem to get rid of the function symbol that shows up upon statically analyzing the binary.

how do i get rid of all function symbols including other public functions my c function may try to use?

Try deleting the associated .pdb file.

Could you specify more precisely what you are doing just to avoid misunderstandings?

For example, "link that C source file to my rust program using cc" requires some interpretation (at least from me).

Oh, if you just want to not have debug symbols for the C library only then you can use .debug(false) when compiling with the cc crate Build in cc - Rust

turned off debug, ran cargo clean, then build release

i still saw the function symbols show up in ghidra as clear as day

// build.rs
cc::Build::new()
    .file("foo.c")
    .compile("foo");

// main.rs
extern "C" {
    fn hello() -> ()
}
1 Like

Did you strip the resulting binary?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.