I'm looking for a Windows equivalent of the GNU tool objcopy. I'm looking to implement the suggestion posted here to my problem, however I need to do it cross-platform (Windows, Linux and Mac). I couldn't find the answer on my google friend, so perhaps the solution needs to be implemented differently. Thank you!
Part of the default MSVC tooling: LIB /EXTRACT
extracts a copy of an object; LIB /REMOVE
then removes it from the library.
I think LIB /DEF /EXPORT:externalName=internalName
also would be beneficial to you, when you put the object file back in.
EXPORT:prefix_Symbol=Symbol
does. –
Marven If you don't mind a hack, replacing all the instances of the conflicting name by a different name of the same length in one of the library bin file can work. Do this at your own risks.
Example
// a.h
void doSomething();
// b.h
void doSomething();
We can replace doSomething
by doSomethink
In python it would be something like:
f = open('b.lib',"rb")
s = f.read()
f.close()
s = s.replace(b'doSomething',b'doSomethink')
f = open('b.lib',"wb")
f.write(s)
f.close()
And modify b header accordingly
// b.h
void doSomethink();
Note that here I used the plain function name as defined in the header to match the symbol in the binary but you might want to use the full mangled name instead to prevent unwanted replacements.
© 2022 - 2024 — McMap. All rights reserved.
objcopy
that you can use straight off. – Width