[llvm-objcopy]Add support for *-freebsd output formats
GNU objcopy can support output formats like elf32-i386-freebsd and
elf64-x86-64-freebsd. The only difference from their regular non-freebsd
counterparts that I have observed is that the freebsd versions set the
OS/ABI field to ELFOSABI_FREEBSD. This patch sets the OS/ABI field
according based on the format whenever --output-format is specified.
Reviewed by: rupprecht, grimar
Differential Revision: https://reviews.llvm.org/D59645
llvm-svn: 356737
diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
index 883ffa0..fc1ac38 100644
--- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -224,8 +224,10 @@
};
if (Error E = DWOFile->removeSections(OnlyKeepDWOPred))
return E;
- if (Config.OutputArch)
+ if (Config.OutputArch) {
DWOFile->Machine = Config.OutputArch.getValue().EMachine;
+ DWOFile->OSABI = Config.OutputArch.getValue().OSABI;
+ }
FileBuffer FB(File);
auto Writer = createWriter(Config, *DWOFile, FB, OutputElfType);
if (Error E = Writer->finalize())
@@ -311,8 +313,10 @@
splitDWOToFile(Config, Reader, Config.SplitDWO, OutputElfType))
return E;
- if (Config.OutputArch)
+ if (Config.OutputArch) {
Obj.Machine = Config.OutputArch.getValue().EMachine;
+ Obj.OSABI = Config.OutputArch.getValue().OSABI;
+ }
// TODO: update or remove symbols only if there is an option that affects
// them.