How can I edit object files on osx? For example, renaming or removing a symbol from an object file. I've tried binutil's gobjcopy:
gobjcopy --strip-symbol some_symbol foo.o foo2.o
This seems to work but ld
complains when linking foo2.o (it didn't complain with foo.o). This also happens in the simplest form (gobjcopy foo.o foo2.o
).
/opt/local/bin/ranlib: file: mylib.a(foo2.o) malformed object (symbol 0 must not have NO_SECT for its n_sect field given its type (N_SECT))
Background: I'm trying to remove a duplicate symbol defined in 2 object files.