1

I have two static third-party libraries which have same exported symbol, and all of symbols I what to use in my shared library. objcopy can redefine symbols from library. After install binutils package from brew, extract all *.o files from static library and call objcopy for each *.o files

objcopy --redefine-sym

pack objects with

ar r *.o

and

ranlib mylib.a

but when I try to compile dymamic library linker show warning:

mylib.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x23 0x31 0x2F 0x32 0x30 0x20 0x20 0x20 

If use objcopy with --output-target mach-o-arm64, linker warning transform to

mylib.a, building for iOS-arm64 but attempting to link with file built for iOS-arm64

It work for x86_64 libraries, but fiasco for arm64..

Fesss
  • 25
  • 5
  • 1
    I think you want `llvm-objcopy`, not GNU `objcopy`. – Siguza May 18 '21 at 18:35
  • mach-o-arm64 is unsupported by [llvm-objcopy](https://llvm.org/docs/CommandGuide/llvm-objcopy.html) – Fesss May 19 '21 at 07:32
  • The clang documentation is enigmatic and virtually always incomplete. Just download [clang 12](https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0), run `llvm-objcopy --redefine-sym=_old=_new in.o out.o` and you'll see that it works. – Siguza May 19 '21 at 17:02
  • This might require a newer version of llvm at this point, can you try by building yourself? At least simple cases work on my machine with llvm @ HEAD – Keith Smiley Dec 03 '21 at 20:22

0 Answers0