mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-02 16:56:50 +00:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273502 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
700dff7358
commit
1a713c6e05
@ -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);
|
||||
|
@ -22,41 +22,13 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user