This patch adds some MachO-specific fields to MachineInfo to
accept MachO formats in -B/-O options.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 37260 Build 37259: arc lint + arc unit
Event Timeline
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
306–307 | The others appear to be: ./objcopy --info | grep ^mach-o | sort -u mach-o-arm mach-o-arm64 mach-o-be mach-o-fat mach-o-i386 mach-o-le mach-o-x86-64 I don't think we need to add them all in this patch, but it'd be nice to see at least one more to make sure the test isn't too rigid. The rest can then be added in a trivial followup patch. (Or you can add them all now). | |
341–344 | -freebsd seems to be an ELF-specific thing -- this should not be consumed if the target does not start with "elf" | |
llvm/tools/llvm-objcopy/CopyConfig.h | ||
52–63 | I don't think this constructor is actually used anymore | |
65–70 | Might be good to extract these to separate types, then initialized like: {"x86-64", {{ELF::EM_X86_64}, {MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_ALL}, true, true} to more clearly separate elf vs mach-o fields (and I imagine we could have COFF fields too) |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
271 | It looks like GNU objcopy doesn't even accept -B x86-64, I wonder if we should consider dropping it. The arch used for that case is actually i386:x86-64. | |
272 | It seems it accepts ~any CPU type (-I binary -B alpha -O mach-o-x86-64 works), though the effects don't seem to be visible (the CpuType/CpuSubType are always X86-64/CPU_SUBTYPE_X86_64_ALL regardless of the -B option). |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
271 | I didn't noticed that. Personally, x86-64 looks intuitive to me but I think it should be removed for the compatibility with GNU objcopy. I'll write a patch for it when I have time. | |
272 | Mach-O supports several CPU types (BinaryFormat/MachO.h). As @rupprecht described, GNU objcopy seems to ignore -B option and use CPUType/CPUSubType specified by -O option. | |
306–307 | Added mach-o-arm64. I'll update the test in D66407 for it. | |
llvm/tools/llvm-objcopy/CopyConfig.h | ||
52–53 | Sounds good idea. Added overloads to MachineInfo. |
Test cases for the new code?
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
271 | I don't think we should drop it. I agree that x86-64 is more intuitive, so if people are in a constrained environment with only the LLVM tools available to them, it's more useful. It's good to add stuff beyond what GNU supports for this reason, if there's a use case. |
I forgot to add NFC in the title. This patch does not introduce new features thus we don't need new tests for it I think.
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
271 |
Makes much sense. |
I wonder if adding another constructor overload might make more sense for usage in the TargetMap table. What do you think?