From 8e783eb75771e1dfd5336b891cf8f1264a575f9a Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 22 Jun 2016 22:19:08 +0000 Subject: [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 --- llvm/lib/Object/MachOUniversal.cpp | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'llvm/lib/Object/MachOUniversal.cpp') 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 @@ -22,41 +22,13 @@ using namespace llvm; using namespace object; -template -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 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; } -- cgit v1.2.3