Skip to content

zeozeozeo/staticlib-fucker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

staticlib-fucker

A utility for mangling names in static object files. Mainly useful for leakage of non-exported symbols in Rust static libraries. (see rust-lang/rust#104707).

This is to prevent collisions of exported symbols when linking multiple Rust static libraries1:

wesl_c.lib(wesl_c.1ichu27y6kwsyom9vxw9s5df9.rcgu.o) : error LNK2005: __rust_no_alloc_shim_is_unstable already defined in wgpu_native.lib(wgpu_native.bxltiha8spj938iuaxui54rnl.rcgu.o)
wesl_c.lib(std-c85e9beb7923f636.std.df32d1bc89881d89-cgu.0.rcgu.o) : error LNK2005: rust_eh_personality already defined in wgpu_native.lib(std-41414eb11fafff20.std.f6fdcf5d182fc0b6-cgu.0.rcgu.o)
fatal error LNK1169: one or more multiply defined symbols found

(Rust shouldn't export these in the first place, but oh well.)

Installation

cargo install staticlib-fucker

or grab one of the Releases

Usage

staticlib-fucker --input mylib.lib --output mylib_mangled.lib

This will mangle rust_eh_personality and __rust_no_alloc_shim_is_unstable by default.

If you want to provide a specific list of symbols to mangle:

staticlib-fucker --input mylib.lib --output mylib_mangled.lib --symbols mysym_1,mysym_2,mysym_3

use --help or -h for help:

A utility for mangling names in static object files. Mainly useful for leakage of non-exported symbols in Rust static libraries. (see https://github.com/rust-lang/rust/issues/104707)

Usage: staticlib-fucker.exe [OPTIONS] --input <INPUT> --output <OUTPUT>

Options:
  -i, --input <INPUT>
  -o, --output <OUTPUT>
      --symbols <SYMBOLS>  [default: __rust_no_alloc_shim_is_unstable,rust_eh_personality]
  -h, --help               Print help
  -V, --version            Print version

Footnotes

  1. https://alanwu.space/post/symbol-hygiene/

About

A utility for mangling names in static object files. Mainly useful for leakage of non-exported symbols in Rust static libraries.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages