summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-06-22 22:19:08 +0000
committerChris Bieneman <beanz@apple.com>2016-06-22 22:19:08 +0000
commit8e783eb75771e1dfd5336b891cf8f1264a575f9a (patch)
tree5c403325a5539c9bdbbef710d77ece0e04ac34ee
parente57bf680ec117a98093c1a0094bcbcabf8d31947 (diff)
downloadbcm5719-llvm-8e783eb75771e1dfd5336b891cf8f1264a575f9a.tar.gz
bcm5719-llvm-8e783eb75771e1dfd5336b891cf8f1264a575f9a.zip
[MachO] Finish moving fat header swap functions to MachO.h
This is a follow-up to r273479. At the time I wrote r273479 I didn't connect the dots that the functions I was adding had to exist somewhere. Turns out, they do. This finishes moving the functions to MachO.h. Existing MachO fat header tests like test/tools/llvm-readobj/Inputs/macho-universal-archive.x86_64.i386 execute this code. llvm-svn: 273502
-rw-r--r--llvm/include/llvm/Support/MachO.h8
-rw-r--r--llvm/lib/Object/MachOUniversal.cpp30
2 files changed, 9 insertions, 29 deletions
diff --git a/llvm/include/llvm/Support/MachO.h b/llvm/include/llvm/Support/MachO.h
index dd885eaf083..9a03722d250 100644
--- a/llvm/include/llvm/Support/MachO.h
+++ b/llvm/include/llvm/Support/MachO.h
@@ -973,6 +973,14 @@ namespace llvm {
sys::swapByteOrder(mh.align);
}
+ inline void swapStruct(fat_arch_64 &mh) {
+ sys::swapByteOrder(mh.cputype);
+ sys::swapByteOrder(mh.cpusubtype);
+ sys::swapByteOrder(mh.offset);
+ sys::swapByteOrder(mh.size);
+ sys::swapByteOrder(mh.align);
+ sys::swapByteOrder(mh.reserved);
+ }
inline void swapStruct(mach_header &mh) {
sys::swapByteOrder(mh.magic);
diff --git a/llvm/lib/Object/MachOUniversal.cpp b/llvm/lib/Object/MachOUniversal.cpp
index 8ccf4de50e0..b3b0c251c10 100644
--- a/llvm/lib/Object/MachOUniversal.cpp
+++ b/llvm/lib/Object/MachOUniversal.cpp
@@ -23,40 +23,12 @@ using namespace llvm;
using namespace object;
template<typename T>
-static void SwapStruct(T &Value);
-
-template<>
-void SwapStruct(MachO::fat_header &H) {
- sys::swapByteOrder(H.magic);
- sys::swapByteOrder(H.nfat_arch);
-}
-
-template<>
-void SwapStruct(MachO::fat_arch &H) {
- sys::swapByteOrder(H.cputype);
- sys::swapByteOrder(H.cpusubtype);
- sys::swapByteOrder(H.offset);
- sys::swapByteOrder(H.size);
- sys::swapByteOrder(H.align);
-}
-
-template<>
-void SwapStruct(MachO::fat_arch_64 &H) {
- sys::swapByteOrder(H.cputype);
- sys::swapByteOrder(H.cpusubtype);
- sys::swapByteOrder(H.offset);
- sys::swapByteOrder(H.size);
- sys::swapByteOrder(H.align);
- sys::swapByteOrder(H.reserved);
-}
-
-template<typename T>
static T getUniversalBinaryStruct(const char *Ptr) {
T Res;
memcpy(&Res, Ptr, sizeof(T));
// Universal binary headers have big-endian byte order.
if (sys::IsLittleEndianHost)
- SwapStruct(Res);
+ swapStruct(Res);
return Res;
}
OpenPOWER on IntegriCloud