This is an archive of the discontinued LLVM Phabricator instance.

[llvm-obcopy][MachO] Add --prefix-symbols support
AbandonedPublic

Authored by keith on Nov 11 2021, 10:48 PM.

Diff Detail

Event Timeline

keith created this revision.Nov 11 2021, 10:48 PM
keith requested review of this revision.Nov 11 2021, 10:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2021, 10:48 PM

I must be missing some cases here, and also need some tests

Take a look at the equivalent ELF test case, to see what cases there are. I imagine the logic is going to be pretty similar.

keith added a comment.Nov 12 2021, 2:14 PM

Take a look at the equivalent ELF test case, to see what cases there are. I imagine the logic is going to be pretty similar.

I did model this after that, I was surprised at how minimal the implementation seemed to be https://github.com/llvm/llvm-project/blob/aab1810006a6788e32ee04e7d40d0b2474754aa2/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L282-L283

Take a look at the equivalent ELF test case, to see what cases there are. I imagine the logic is going to be pretty similar.

I did model this after that, I was surprised at how minimal the implementation seemed to be https://github.com/llvm/llvm-project/blob/aab1810006a6788e32ee04e7d40d0b2474754aa2/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L282-L283

Sorry, I meant that comment as a suggestion for how to test it - the existing ELF tests should provide a reasonable framework for how to test this in Mach-O, I imagine.

The implementation is simple because the symbol table is rewritten from scratch by llvm-objcopy, so all that has to be updated is the internal symbol's name.

keith abandoned this revision.Nov 15 2021, 3:15 PM

Take a look at the equivalent ELF test case, to see what cases there are. I imagine the logic is going to be pretty similar.

I did model this after that, I was surprised at how minimal the implementation seemed to be https://github.com/llvm/llvm-project/blob/aab1810006a6788e32ee04e7d40d0b2474754aa2/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L282-L283

Sorry, I meant that comment as a suggestion for how to test it - the existing ELF tests should provide a reasonable framework for how to test this in Mach-O, I imagine.

The implementation is simple because the symbol table is rewritten from scratch by llvm-objcopy, so all that has to be updated is the internal symbol's name.

Ah got it thanks. Given this conversation https://groups.google.com/g/llvm-dev/c/A26kbQhZ9Po I'm going to drop this for now since this doesn't seem to do what I hoped. For others --redefine-syms may solve your use case instead.