Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Strip symbol names from output #345

Open
brson opened this issue Sep 7, 2023 · 4 comments
Open

Strip symbol names from output #345

brson opened this issue Sep 7, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@brson
Copy link
Collaborator

brson commented Sep 7, 2023

rbpf does not allow symbol names greater than 64 bytes, and in #303 I have needed to generate symbol names larger than that. rustc generates huge symbol names but they are stripped before running on solana.

It seems that we have just been lucky that move-native has not generated any huge symbol names, as that library is not stripped.

Solana does this in the cargo-build-sbf tool by using its strip.sh script. That script essentially just calls llvm-objcopy --strip-all on the .so file.

I am unsure where exactly we should do this. For now we might be able to just do it in rbpf-tests.

@brson brson added the enhancement New feature or request label Sep 7, 2023
@brson
Copy link
Collaborator Author

brson commented Sep 7, 2023

After further experiments I don't think stripping solves my problems from #303.

Stripping does not remove symbol names from the dynamic symbol table (.dynsym), and that is where the large symbols are.

So this is probably still needed for production, but does not solve my immediate problems.

@dmakarov
Copy link
Collaborator

dmakarov commented Sep 7, 2023

In rbpf-tests.rs the linker command already adds an option to strip all symbols. We might have to keep move-native symbols short or replace them by hashes, assuming we can avoid collisions.

@dmakarov
Copy link
Collaborator

dmakarov commented Sep 7, 2023

We already strip all symbols that are not exported.

When move build links the final .so file it strips all the symbols. https://github.com/solana-labs/move/blob/eda1dcf69a816a2732d88a80d6f31b459d775066/language/solana/move-to-solana/src/lib.rs#L275
and this is in rbpf-tests.rs when linking the final binary https://github.com/solana-labs/move/blob/eda1dcf69a816a2732d88a80d6f31b459d775066/language/tools/move-mv-llvm-compiler/tests/rbpf-tests.rs#L278

@ksolana
Copy link
Collaborator

ksolana commented Sep 10, 2023

yeah i remember we ran into this issue only a while back and @dmakarov found out this issue with long symbol names. I we'll get linker error if long symbol names are present in a binary for some reason.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants