I have multiple Fortran static libraries which have functions with the same name, that I'd like to call from Rust. Using objcopy
prefixing, I can make the names unique, as shown here:
ld -r obj1.o obj2.o ... objn.o -o static1.o
objcopy --localize-hidden --prefix-symbols=foo static1.o static2.o
ar -rcs mylib.a static2.o
However, it seems that objcopy
prefixes all symbols, even the ones that only appear as a function call to an external library. Thus, I get errors such as:
/usr/bin/ld: (.text+0xaf0c): undefined reference to `foo_gfortran_runtime_error_at'
It seem then that I only want to rename the symbols that are marked as T
in nm
. Is this correct? Is there a way to do this with objcopy
or ld
?
Do you also know of a solution that works on Mac as well (where objcopy
is unavailable)?