mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
Add printing the LC_THREAD load commands with llvm-objdump’s -private-headers.
llvm-svn: 224792
This commit is contained in:
parent
7c74b14d55
commit
3c109420ec
@ -380,6 +380,8 @@ public:
|
||||
getRoutinesCommand(const LoadCommandInfo &L) const;
|
||||
MachO::routines_command_64
|
||||
getRoutinesCommand64(const LoadCommandInfo &L) const;
|
||||
MachO::thread_command
|
||||
getThreadCommand(const LoadCommandInfo &L) const;
|
||||
|
||||
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const;
|
||||
MachO::data_in_code_entry getDice(DataRefImpl Rel) const;
|
||||
|
@ -1157,6 +1157,11 @@ namespace llvm {
|
||||
sys::swapByteOrder(r.reserved6);
|
||||
}
|
||||
|
||||
inline void swapStruct(thread_command &t) {
|
||||
sys::swapByteOrder(t.cmd);
|
||||
sys::swapByteOrder(t.cmdsize);
|
||||
}
|
||||
|
||||
inline void swapStruct(dylinker_command &d) {
|
||||
sys::swapByteOrder(d.cmd);
|
||||
sys::swapByteOrder(d.cmdsize);
|
||||
@ -1413,6 +1418,262 @@ namespace llvm {
|
||||
CPU_SUBTYPE_MC980000_ALL = CPU_SUBTYPE_POWERPC_ALL,
|
||||
CPU_SUBTYPE_MC98601 = CPU_SUBTYPE_POWERPC_601
|
||||
};
|
||||
|
||||
struct x86_thread_state64_t {
|
||||
uint64_t rax;
|
||||
uint64_t rbx;
|
||||
uint64_t rcx;
|
||||
uint64_t rdx;
|
||||
uint64_t rdi;
|
||||
uint64_t rsi;
|
||||
uint64_t rbp;
|
||||
uint64_t rsp;
|
||||
uint64_t r8;
|
||||
uint64_t r9;
|
||||
uint64_t r10;
|
||||
uint64_t r11;
|
||||
uint64_t r12;
|
||||
uint64_t r13;
|
||||
uint64_t r14;
|
||||
uint64_t r15;
|
||||
uint64_t rip;
|
||||
uint64_t rflags;
|
||||
uint64_t cs;
|
||||
uint64_t fs;
|
||||
uint64_t gs;
|
||||
};
|
||||
|
||||
enum x86_fp_control_precis {
|
||||
x86_FP_PREC_24B = 0,
|
||||
x86_FP_PREC_53B = 2,
|
||||
x86_FP_PREC_64B = 3
|
||||
};
|
||||
|
||||
enum x86_fp_control_rc {
|
||||
x86_FP_RND_NEAR = 0,
|
||||
x86_FP_RND_DOWN = 1,
|
||||
x86_FP_RND_UP = 2,
|
||||
x86_FP_CHOP = 3
|
||||
};
|
||||
|
||||
struct fp_control_t {
|
||||
unsigned short
|
||||
invalid :1,
|
||||
denorm :1,
|
||||
zdiv :1,
|
||||
ovrfl :1,
|
||||
undfl :1,
|
||||
precis :1,
|
||||
:2,
|
||||
pc :2,
|
||||
rc :2,
|
||||
:1,
|
||||
:3;
|
||||
};
|
||||
|
||||
struct fp_status_t {
|
||||
unsigned short
|
||||
invalid :1,
|
||||
denorm :1,
|
||||
zdiv :1,
|
||||
ovrfl :1,
|
||||
undfl :1,
|
||||
precis :1,
|
||||
stkflt :1,
|
||||
errsumm :1,
|
||||
c0 :1,
|
||||
c1 :1,
|
||||
c2 :1,
|
||||
tos :3,
|
||||
c3 :1,
|
||||
busy :1;
|
||||
};
|
||||
|
||||
struct mmst_reg {
|
||||
char mmst_reg[10];
|
||||
char mmst_rsrv[6];
|
||||
};
|
||||
|
||||
struct xmm_reg {
|
||||
char xmm_reg[16];
|
||||
};
|
||||
|
||||
struct x86_float_state64_t {
|
||||
int32_t fpu_reserved[2];
|
||||
fp_control_t fpu_fcw;
|
||||
fp_status_t fpu_fsw;
|
||||
uint8_t fpu_ftw;
|
||||
uint8_t fpu_rsrv1;
|
||||
uint16_t fpu_fop;
|
||||
uint32_t fpu_ip;
|
||||
uint16_t fpu_cs;
|
||||
uint16_t fpu_rsrv2;
|
||||
uint32_t fpu_dp;
|
||||
uint16_t fpu_ds;
|
||||
uint16_t fpu_rsrv3;
|
||||
uint32_t fpu_mxcsr;
|
||||
uint32_t fpu_mxcsrmask;
|
||||
mmst_reg fpu_stmm0;
|
||||
mmst_reg fpu_stmm1;
|
||||
mmst_reg fpu_stmm2;
|
||||
mmst_reg fpu_stmm3;
|
||||
mmst_reg fpu_stmm4;
|
||||
mmst_reg fpu_stmm5;
|
||||
mmst_reg fpu_stmm6;
|
||||
mmst_reg fpu_stmm7;
|
||||
xmm_reg fpu_xmm0;
|
||||
xmm_reg fpu_xmm1;
|
||||
xmm_reg fpu_xmm2;
|
||||
xmm_reg fpu_xmm3;
|
||||
xmm_reg fpu_xmm4;
|
||||
xmm_reg fpu_xmm5;
|
||||
xmm_reg fpu_xmm6;
|
||||
xmm_reg fpu_xmm7;
|
||||
xmm_reg fpu_xmm8;
|
||||
xmm_reg fpu_xmm9;
|
||||
xmm_reg fpu_xmm10;
|
||||
xmm_reg fpu_xmm11;
|
||||
xmm_reg fpu_xmm12;
|
||||
xmm_reg fpu_xmm13;
|
||||
xmm_reg fpu_xmm14;
|
||||
xmm_reg fpu_xmm15;
|
||||
char fpu_rsrv4[6*16];
|
||||
uint32_t fpu_reserved1;
|
||||
};
|
||||
|
||||
struct x86_exception_state64_t {
|
||||
uint16_t trapno;
|
||||
uint16_t cpu;
|
||||
uint32_t err;
|
||||
uint64_t faultvaddr;
|
||||
};
|
||||
|
||||
inline void swapStruct(x86_thread_state64_t &x) {
|
||||
sys::swapByteOrder(x.rax);
|
||||
sys::swapByteOrder(x.rbx);
|
||||
sys::swapByteOrder(x.rcx);
|
||||
sys::swapByteOrder(x.rdx);
|
||||
sys::swapByteOrder(x.rdi);
|
||||
sys::swapByteOrder(x.rsi);
|
||||
sys::swapByteOrder(x.rbp);
|
||||
sys::swapByteOrder(x.rsp);
|
||||
sys::swapByteOrder(x.r8);
|
||||
sys::swapByteOrder(x.r9);
|
||||
sys::swapByteOrder(x.r10);
|
||||
sys::swapByteOrder(x.r11);
|
||||
sys::swapByteOrder(x.r12);
|
||||
sys::swapByteOrder(x.r13);
|
||||
sys::swapByteOrder(x.r14);
|
||||
sys::swapByteOrder(x.r15);
|
||||
sys::swapByteOrder(x.rip);
|
||||
sys::swapByteOrder(x.rflags);
|
||||
sys::swapByteOrder(x.cs);
|
||||
sys::swapByteOrder(x.fs);
|
||||
sys::swapByteOrder(x.gs);
|
||||
}
|
||||
|
||||
inline void swapStruct(x86_float_state64_t &x) {
|
||||
sys::swapByteOrder(x.fpu_reserved[0]);
|
||||
sys::swapByteOrder(x.fpu_reserved[1]);
|
||||
// TODO swap: fp_control_t fpu_fcw;
|
||||
// TODO swap: fp_status_t fpu_fsw;
|
||||
sys::swapByteOrder(x.fpu_fop);
|
||||
sys::swapByteOrder(x.fpu_ip);
|
||||
sys::swapByteOrder(x.fpu_cs);
|
||||
sys::swapByteOrder(x.fpu_rsrv2);
|
||||
sys::swapByteOrder(x.fpu_dp);
|
||||
sys::swapByteOrder(x.fpu_ds);
|
||||
sys::swapByteOrder(x.fpu_rsrv3);
|
||||
sys::swapByteOrder(x.fpu_mxcsr);
|
||||
sys::swapByteOrder(x.fpu_mxcsrmask);
|
||||
sys::swapByteOrder(x.fpu_reserved1);
|
||||
}
|
||||
|
||||
inline void swapStruct(x86_exception_state64_t &x) {
|
||||
sys::swapByteOrder(x.trapno);
|
||||
sys::swapByteOrder(x.cpu);
|
||||
sys::swapByteOrder(x.err);
|
||||
sys::swapByteOrder(x.faultvaddr);
|
||||
}
|
||||
|
||||
struct x86_state_hdr_t {
|
||||
uint32_t flavor;
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
struct x86_thread_state_t {
|
||||
x86_state_hdr_t tsh;
|
||||
union {
|
||||
x86_thread_state64_t ts64;
|
||||
} uts;
|
||||
};
|
||||
|
||||
struct x86_float_state_t {
|
||||
x86_state_hdr_t fsh;
|
||||
union {
|
||||
x86_float_state64_t fs64;
|
||||
} ufs;
|
||||
};
|
||||
|
||||
struct x86_exception_state_t {
|
||||
x86_state_hdr_t esh;
|
||||
union {
|
||||
x86_exception_state64_t es64;
|
||||
} ues;
|
||||
};
|
||||
|
||||
inline void swapStruct(x86_state_hdr_t &x) {
|
||||
sys::swapByteOrder(x.flavor);
|
||||
sys::swapByteOrder(x.count);
|
||||
}
|
||||
|
||||
enum X86ThreadFlavors {
|
||||
x86_THREAD_STATE32 = 1,
|
||||
x86_FLOAT_STATE32 = 2,
|
||||
x86_EXCEPTION_STATE32 = 3,
|
||||
x86_THREAD_STATE64 = 4,
|
||||
x86_FLOAT_STATE64 = 5,
|
||||
x86_EXCEPTION_STATE64 = 6,
|
||||
x86_THREAD_STATE = 7,
|
||||
x86_FLOAT_STATE = 8,
|
||||
x86_EXCEPTION_STATE = 9,
|
||||
x86_DEBUG_STATE32 = 10,
|
||||
x86_DEBUG_STATE64 = 11,
|
||||
x86_DEBUG_STATE = 12
|
||||
};
|
||||
|
||||
inline void swapStruct(x86_thread_state_t &x) {
|
||||
swapStruct(x.tsh);
|
||||
if (x.tsh.flavor == x86_THREAD_STATE64)
|
||||
swapStruct(x.uts.ts64);
|
||||
}
|
||||
|
||||
inline void swapStruct(x86_float_state_t &x) {
|
||||
swapStruct(x.fsh);
|
||||
if (x.fsh.flavor == x86_FLOAT_STATE64)
|
||||
swapStruct(x.ufs.fs64);
|
||||
}
|
||||
|
||||
inline void swapStruct(x86_exception_state_t &x) {
|
||||
swapStruct(x.esh);
|
||||
if (x.esh.flavor == x86_EXCEPTION_STATE64)
|
||||
swapStruct(x.ues.es64);
|
||||
}
|
||||
|
||||
const uint32_t x86_THREAD_STATE64_COUNT =
|
||||
sizeof(x86_thread_state64_t) / sizeof(uint32_t);
|
||||
const uint32_t x86_FLOAT_STATE64_COUNT =
|
||||
sizeof(x86_float_state64_t) / sizeof(uint32_t);
|
||||
const uint32_t x86_EXCEPTION_STATE64_COUNT =
|
||||
sizeof(x86_exception_state64_t) / sizeof(uint32_t);
|
||||
|
||||
const uint32_t x86_THREAD_STATE_COUNT =
|
||||
sizeof(x86_thread_state_t) / sizeof(uint32_t);
|
||||
const uint32_t x86_FLOAT_STATE_COUNT =
|
||||
sizeof(x86_float_state_t) / sizeof(uint32_t);
|
||||
const uint32_t x86_EXCEPTION_STATE_COUNT =
|
||||
sizeof(x86_exception_state_t) / sizeof(uint32_t);
|
||||
|
||||
} // end namespace MachO
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -2342,6 +2342,11 @@ MachOObjectFile::getRoutinesCommand64(const LoadCommandInfo &L) const {
|
||||
return getStruct<MachO::routines_command_64>(this, L.Ptr);
|
||||
}
|
||||
|
||||
MachO::thread_command
|
||||
MachOObjectFile::getThreadCommand(const LoadCommandInfo &L) const {
|
||||
return getStruct<MachO::thread_command>(this, L.Ptr);
|
||||
}
|
||||
|
||||
MachO::any_relocation_info
|
||||
MachOObjectFile::getRelocation(DataRefImpl Rel) const {
|
||||
DataRefImpl Sec;
|
||||
|
BIN
test/tools/llvm-objdump/X86/Inputs/exeThread.macho-x86_64
Executable file
BIN
test/tools/llvm-objdump/X86/Inputs/exeThread.macho-x86_64
Executable file
Binary file not shown.
@ -15,6 +15,8 @@
|
||||
// RUN: | FileCheck %s -check-prefix=SUB_CLI
|
||||
// RUN: llvm-objdump -p %p/Inputs/dylibRoutines.macho-x86_64 \
|
||||
// RUN: | FileCheck %s -check-prefix=ROUTINE
|
||||
// RUN: llvm-objdump -p %p/Inputs/exeThread.macho-x86_64 \
|
||||
// RUN: | FileCheck %s -check-prefix=THREAD
|
||||
|
||||
CHECK: Mach header
|
||||
CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
|
||||
@ -421,3 +423,17 @@ ROUTINE: reserved3 0
|
||||
ROUTINE: reserved4 0
|
||||
ROUTINE: reserved5 0
|
||||
ROUTINE: reserved6 0
|
||||
|
||||
THREAD: Load command 10
|
||||
THREAD: cmd LC_UNIXTHREAD
|
||||
THREAD: cmdsize 184
|
||||
THREAD: flavor x86_THREAD_STATE64
|
||||
THREAD: count x86_THREAD_STATE64_COUNT
|
||||
THREAD: rax 0x0000000000000000 rbx 0x0000000000000000 rcx 0x0000000000000000
|
||||
THREAD: rdx 0x0000000000000000 rdi 0x0000000000000000 rsi 0x0000000000000000
|
||||
THREAD: rbp 0x0000000000000000 rsp 0x0000000000000000 r8 0x0000000000000000
|
||||
THREAD: r9 0x0000000000000000 r10 0x0000000000000000 r11 0x0000000000000000
|
||||
THREAD: r12 0x0000000000000000 r13 0x0000000000000000 r14 0x0000000000000000
|
||||
THREAD: r15 0x0000000000000000 rip 0x0000000100000d00
|
||||
THREAD: rflags 0x0000000000000000 cs 0x0000000000000000 fs 0x0000000000000000
|
||||
THREAD: gs 0x0000000000000000
|
||||
|
@ -3773,6 +3773,354 @@ static void PrintRoutinesCommand64(MachO::routines_command_64 r) {
|
||||
outs() << " reserved6 " << r.reserved6 << "\n";
|
||||
}
|
||||
|
||||
static void Print_x86_thread_state64_t(MachO::x86_thread_state64_t &cpu64) {
|
||||
outs() << " rax " << format("0x%016" PRIx64, cpu64.rax);
|
||||
outs() << " rbx " << format("0x%016" PRIx64, cpu64.rbx);
|
||||
outs() << " rcx " << format("0x%016" PRIx64, cpu64.rcx) << "\n";
|
||||
outs() << " rdx " << format("0x%016" PRIx64, cpu64.rdx);
|
||||
outs() << " rdi " << format("0x%016" PRIx64, cpu64.rdi);
|
||||
outs() << " rsi " << format("0x%016" PRIx64, cpu64.rsi) << "\n";
|
||||
outs() << " rbp " << format("0x%016" PRIx64, cpu64.rbp);
|
||||
outs() << " rsp " << format("0x%016" PRIx64, cpu64.rsp);
|
||||
outs() << " r8 " << format("0x%016" PRIx64, cpu64.r8) << "\n";
|
||||
outs() << " r9 " << format("0x%016" PRIx64, cpu64.r9);
|
||||
outs() << " r10 " << format("0x%016" PRIx64, cpu64.r10);
|
||||
outs() << " r11 " << format("0x%016" PRIx64, cpu64.r11) << "\n";
|
||||
outs() << " r12 " << format("0x%016" PRIx64, cpu64.r12);
|
||||
outs() << " r13 " << format("0x%016" PRIx64, cpu64.r13);
|
||||
outs() << " r14 " << format("0x%016" PRIx64, cpu64.r14) << "\n";
|
||||
outs() << " r15 " << format("0x%016" PRIx64, cpu64.r15);
|
||||
outs() << " rip " << format("0x%016" PRIx64, cpu64.rip) << "\n";
|
||||
outs() << "rflags " << format("0x%016" PRIx64, cpu64.rflags);
|
||||
outs() << " cs " << format("0x%016" PRIx64, cpu64.cs);
|
||||
outs() << " fs " << format("0x%016" PRIx64, cpu64.fs) << "\n";
|
||||
outs() << " gs " << format("0x%016" PRIx64, cpu64.gs) << "\n";
|
||||
}
|
||||
|
||||
static void Print_mmst_reg(MachO::mmst_reg &r) {
|
||||
uint32_t f;
|
||||
outs() << "\t mmst_reg ";
|
||||
for (f = 0; f < 10; f++)
|
||||
outs() << format("%02" PRIx32, (r.mmst_reg[f] & 0xff)) << " ";
|
||||
outs() << "\n";
|
||||
outs() << "\t mmst_rsrv ";
|
||||
for (f = 0; f < 6; f++)
|
||||
outs() << format("%02" PRIx32, (r.mmst_rsrv[f] & 0xff)) << " ";
|
||||
outs() << "\n";
|
||||
}
|
||||
|
||||
static void Print_xmm_reg(MachO::xmm_reg &r) {
|
||||
uint32_t f;
|
||||
outs() << "\t xmm_reg ";
|
||||
for (f = 0; f < 16; f++)
|
||||
outs() << format("%02" PRIx32, (r.xmm_reg[f] & 0xff)) << " ";
|
||||
outs() << "\n";
|
||||
}
|
||||
|
||||
static void Print_x86_float_state_t(MachO::x86_float_state64_t &fpu) {
|
||||
outs() << "\t fpu_reserved[0] " << fpu.fpu_reserved[0];
|
||||
outs() << " fpu_reserved[1] " << fpu.fpu_reserved[1] << "\n";
|
||||
outs() << "\t control: invalid " << fpu.fpu_fcw.invalid;
|
||||
outs() << " denorm " << fpu.fpu_fcw.denorm;
|
||||
outs() << " zdiv " << fpu.fpu_fcw.zdiv;
|
||||
outs() << " ovrfl " << fpu.fpu_fcw.ovrfl;
|
||||
outs() << " undfl " << fpu.fpu_fcw.undfl;
|
||||
outs() << " precis " << fpu.fpu_fcw.precis << "\n";
|
||||
outs() << "\t\t pc ";
|
||||
if (fpu.fpu_fcw.pc == MachO::x86_FP_PREC_24B)
|
||||
outs() << "FP_PREC_24B ";
|
||||
else if (fpu.fpu_fcw.pc == MachO::x86_FP_PREC_53B)
|
||||
outs() << "FP_PREC_53B ";
|
||||
else if (fpu.fpu_fcw.pc == MachO::x86_FP_PREC_64B)
|
||||
outs() << "FP_PREC_64B ";
|
||||
else
|
||||
outs() << fpu.fpu_fcw.pc << " ";
|
||||
outs() << "rc ";
|
||||
if (fpu.fpu_fcw.rc == MachO::x86_FP_RND_NEAR)
|
||||
outs() << "FP_RND_NEAR ";
|
||||
else if (fpu.fpu_fcw.rc == MachO::x86_FP_RND_DOWN)
|
||||
outs() << "FP_RND_DOWN ";
|
||||
else if (fpu.fpu_fcw.rc == MachO::x86_FP_RND_UP)
|
||||
outs() << "FP_RND_UP ";
|
||||
else if (fpu.fpu_fcw.rc == MachO::x86_FP_CHOP)
|
||||
outs() << "FP_CHOP ";
|
||||
outs() << "\n";
|
||||
outs() << "\t status: invalid " << fpu.fpu_fsw.invalid;
|
||||
outs() << " denorm " << fpu.fpu_fsw.denorm;
|
||||
outs() << " zdiv " << fpu.fpu_fsw.zdiv;
|
||||
outs() << " ovrfl " << fpu.fpu_fsw.ovrfl;
|
||||
outs() << " undfl " << fpu.fpu_fsw.undfl;
|
||||
outs() << " precis " << fpu.fpu_fsw.precis;
|
||||
outs() << " stkflt " << fpu.fpu_fsw.stkflt << "\n";
|
||||
outs() << "\t errsumm " << fpu.fpu_fsw.errsumm;
|
||||
outs() << " c0 " << fpu.fpu_fsw.c0;
|
||||
outs() << " c1 " << fpu.fpu_fsw.c1;
|
||||
outs() << " c2 " << fpu.fpu_fsw.c2;
|
||||
outs() << " tos " << fpu.fpu_fsw.tos;
|
||||
outs() << " c3 " << fpu.fpu_fsw.c3;
|
||||
outs() << " busy " << fpu.fpu_fsw.busy << "\n";
|
||||
outs() << "\t fpu_ftw " << format("0x%02" PRIx32, fpu.fpu_ftw);
|
||||
outs() << " fpu_rsrv1 " << format("0x%02" PRIx32, fpu.fpu_rsrv1);
|
||||
outs() << " fpu_fop " << format("0x%04" PRIx32, fpu.fpu_fop);
|
||||
outs() << " fpu_ip " << format("0x%08" PRIx32, fpu.fpu_ip) << "\n";
|
||||
outs() << "\t fpu_cs " << format("0x%04" PRIx32, fpu.fpu_cs);
|
||||
outs() << " fpu_rsrv2 " << format("0x%04" PRIx32, fpu.fpu_rsrv2);
|
||||
outs() << " fpu_dp " << format("0x%08" PRIx32, fpu.fpu_dp);
|
||||
outs() << " fpu_ds " << format("0x%04" PRIx32, fpu.fpu_ds) << "\n";
|
||||
outs() << "\t fpu_rsrv3 " << format("0x%04" PRIx32, fpu.fpu_rsrv3);
|
||||
outs() << " fpu_mxcsr " << format("0x%08" PRIx32, fpu.fpu_mxcsr);
|
||||
outs() << " fpu_mxcsrmask " << format("0x%08" PRIx32, fpu.fpu_mxcsrmask);
|
||||
outs() << "\n";
|
||||
outs() << "\t fpu_stmm0:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm0);
|
||||
outs() << "\t fpu_stmm1:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm1);
|
||||
outs() << "\t fpu_stmm2:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm2);
|
||||
outs() << "\t fpu_stmm3:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm3);
|
||||
outs() << "\t fpu_stmm4:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm4);
|
||||
outs() << "\t fpu_stmm5:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm5);
|
||||
outs() << "\t fpu_stmm6:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm6);
|
||||
outs() << "\t fpu_stmm7:\n";
|
||||
Print_mmst_reg(fpu.fpu_stmm7);
|
||||
outs() << "\t fpu_xmm0:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm0);
|
||||
outs() << "\t fpu_xmm1:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm1);
|
||||
outs() << "\t fpu_xmm2:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm2);
|
||||
outs() << "\t fpu_xmm3:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm3);
|
||||
outs() << "\t fpu_xmm4:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm4);
|
||||
outs() << "\t fpu_xmm5:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm5);
|
||||
outs() << "\t fpu_xmm6:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm6);
|
||||
outs() << "\t fpu_xmm7:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm7);
|
||||
outs() << "\t fpu_xmm8:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm8);
|
||||
outs() << "\t fpu_xmm9:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm9);
|
||||
outs() << "\t fpu_xmm10:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm10);
|
||||
outs() << "\t fpu_xmm11:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm11);
|
||||
outs() << "\t fpu_xmm12:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm12);
|
||||
outs() << "\t fpu_xmm13:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm13);
|
||||
outs() << "\t fpu_xmm14:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm14);
|
||||
outs() << "\t fpu_xmm15:\n";
|
||||
Print_xmm_reg(fpu.fpu_xmm15);
|
||||
outs() << "\t fpu_rsrv4:\n";
|
||||
for (uint32_t f = 0; f < 6; f++) {
|
||||
outs() << "\t ";
|
||||
for (uint32_t g = 0; g < 16; g++)
|
||||
outs() << format("%02" PRIx32, fpu.fpu_rsrv4[f*g]) << " ";
|
||||
outs() << "\n";
|
||||
}
|
||||
outs() << "\t fpu_reserved1 " << format("0x%08" PRIx32, fpu.fpu_reserved1);
|
||||
outs() << "\n";
|
||||
}
|
||||
|
||||
static void Print_x86_exception_state_t(MachO::x86_exception_state64_t &exc64) {
|
||||
outs() << "\t trapno " << format("0x%08" PRIx32, exc64.trapno);
|
||||
outs() << " err " << format("0x%08" PRIx32, exc64.err);
|
||||
outs() << " faultvaddr " << format("0x%016" PRIx64, exc64.faultvaddr) << "\n";
|
||||
}
|
||||
|
||||
static void PrintThreadCommand(MachO::thread_command t, const char *Ptr,
|
||||
bool isLittleEndian, uint32_t cputype) {
|
||||
if (t.cmd == MachO::LC_THREAD)
|
||||
outs() << " cmd LC_THREAD\n";
|
||||
else if (t.cmd == MachO::LC_UNIXTHREAD)
|
||||
outs() << " cmd LC_UNIXTHREAD\n";
|
||||
else
|
||||
outs() << " cmd " << t.cmd << " (unknown)\n";
|
||||
outs() << " cmdsize " << t.cmdsize;
|
||||
if (t.cmdsize < sizeof(struct MachO::thread_command) + 2 * sizeof(uint32_t))
|
||||
outs() << " Incorrect size\n";
|
||||
else
|
||||
outs() << "\n";
|
||||
|
||||
const char *begin = Ptr + sizeof(struct MachO::thread_command);
|
||||
const char *end = Ptr + t.cmdsize;
|
||||
uint32_t flavor, count, left;
|
||||
if (cputype == MachO::CPU_TYPE_X86_64) {
|
||||
while (begin < end) {
|
||||
if (end - begin > (ptrdiff_t)sizeof(uint32_t)) {
|
||||
memcpy((char *)&flavor, begin, sizeof(uint32_t));
|
||||
begin += sizeof(uint32_t);
|
||||
} else{
|
||||
flavor = 0;
|
||||
begin = end;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
sys::swapByteOrder(flavor);
|
||||
if (end - begin > (ptrdiff_t)sizeof(uint32_t)) {
|
||||
memcpy((char *)&count, begin, sizeof(uint32_t));
|
||||
begin += sizeof(uint32_t);
|
||||
} else{
|
||||
count = 0;
|
||||
begin = end;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
sys::swapByteOrder(count);
|
||||
if (flavor == MachO::x86_THREAD_STATE64) {
|
||||
outs() << " flavor x86_THREAD_STATE64\n";
|
||||
if (count == MachO::x86_THREAD_STATE64_COUNT)
|
||||
outs() << " count x86_THREAD_STATE64_COUNT\n";
|
||||
else
|
||||
outs() << " count " << count
|
||||
<< " (not x86_THREAD_STATE64_COUNT)\n";
|
||||
MachO::x86_thread_state64_t cpu64;
|
||||
left = end - begin;
|
||||
if (left >= sizeof(MachO::x86_thread_state64_t)) {
|
||||
memcpy(&cpu64, begin, sizeof(MachO::x86_thread_state64_t));
|
||||
begin += sizeof(MachO::x86_thread_state64_t);
|
||||
} else {
|
||||
memset(&cpu64, '\0', sizeof(MachO::x86_thread_state64_t));
|
||||
memcpy(&cpu64, begin, left);
|
||||
begin += left;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
swapStruct(cpu64);
|
||||
Print_x86_thread_state64_t(cpu64);
|
||||
} else if (flavor == MachO::x86_THREAD_STATE) {
|
||||
outs() << " flavor x86_THREAD_STATE\n";
|
||||
if (count == MachO::x86_THREAD_STATE_COUNT)
|
||||
outs() << " count x86_THREAD_STATE_COUNT\n";
|
||||
else
|
||||
outs() << " count " << count
|
||||
<< " (not x86_THREAD_STATE_COUNT)\n";
|
||||
struct MachO::x86_thread_state_t ts;
|
||||
left = end - begin;
|
||||
if (left >= sizeof(MachO::x86_thread_state_t)) {
|
||||
memcpy(&ts, begin, sizeof(MachO::x86_thread_state_t));
|
||||
begin += sizeof(MachO::x86_thread_state_t);
|
||||
} else {
|
||||
memset(&ts, '\0', sizeof(MachO::x86_thread_state_t));
|
||||
memcpy(&ts, begin, left);
|
||||
begin += left;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
swapStruct(ts);
|
||||
if (ts.tsh.flavor == MachO::x86_THREAD_STATE64) {
|
||||
outs() << "\t tsh.flavor x86_THREAD_STATE64 ";
|
||||
if (ts.tsh.count == MachO::x86_THREAD_STATE64_COUNT)
|
||||
outs() << "tsh.count x86_THREAD_STATE64_COUNT\n";
|
||||
else
|
||||
outs() << "tsh.count " << ts.tsh.count
|
||||
<< " (not x86_THREAD_STATE64_COUNT\n";
|
||||
Print_x86_thread_state64_t(ts.uts.ts64);
|
||||
} else {
|
||||
outs() << "\t tsh.flavor " << ts.tsh.flavor
|
||||
<< " tsh.count " << ts.tsh.count << "\n";
|
||||
}
|
||||
} else if (flavor == MachO::x86_FLOAT_STATE) {
|
||||
outs() << " flavor x86_FLOAT_STATE\n";
|
||||
if (count == MachO::x86_FLOAT_STATE_COUNT)
|
||||
outs() << " count x86_FLOAT_STATE_COUNT\n";
|
||||
else
|
||||
outs() << " count " << count
|
||||
<< " (not x86_FLOAT_STATE_COUNT)\n";
|
||||
struct MachO::x86_float_state_t fs;
|
||||
left = end - begin;
|
||||
if (left >= sizeof(MachO::x86_float_state_t)) {
|
||||
memcpy(&fs, begin, sizeof(MachO::x86_float_state_t));
|
||||
begin += sizeof(MachO::x86_float_state_t);
|
||||
} else {
|
||||
memset(&fs, '\0', sizeof(MachO::x86_float_state_t));
|
||||
memcpy(&fs, begin, left);
|
||||
begin += left;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
swapStruct(fs);
|
||||
if (fs.fsh.flavor == MachO::x86_FLOAT_STATE64) {
|
||||
outs() << "\t fsh.flavor x86_FLOAT_STATE64 ";
|
||||
if (fs.fsh.count == MachO::x86_FLOAT_STATE64_COUNT)
|
||||
outs() << "fsh.count x86_FLOAT_STATE64_COUNT\n";
|
||||
else
|
||||
outs() << "fsh.count " << fs.fsh.count
|
||||
<< " (not x86_FLOAT_STATE64_COUNT\n";
|
||||
Print_x86_float_state_t(fs.ufs.fs64);
|
||||
} else {
|
||||
outs() << "\t fsh.flavor " << fs.fsh.flavor
|
||||
<< " fsh.count " << fs.fsh.count << "\n";
|
||||
}
|
||||
} else if (flavor == MachO::x86_EXCEPTION_STATE) {
|
||||
outs() << " flavor x86_EXCEPTION_STATE\n";
|
||||
if (count == MachO::x86_EXCEPTION_STATE_COUNT)
|
||||
outs() << " count x86_EXCEPTION_STATE_COUNT\n";
|
||||
else
|
||||
outs() << " count " << count
|
||||
<< " (not x86_EXCEPTION_STATE_COUNT)\n";
|
||||
struct MachO::x86_exception_state_t es;
|
||||
left = end - begin;
|
||||
if (left >= sizeof(MachO::x86_exception_state_t)) {
|
||||
memcpy(&es, begin, sizeof(MachO::x86_exception_state_t));
|
||||
begin += sizeof(MachO::x86_exception_state_t);
|
||||
} else {
|
||||
memset(&es, '\0', sizeof(MachO::x86_exception_state_t));
|
||||
memcpy(&es, begin, left);
|
||||
begin += left;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
swapStruct(es);
|
||||
if (es.esh.flavor == MachO::x86_EXCEPTION_STATE64) {
|
||||
outs() << "\t esh.flavor x86_EXCEPTION_STATE64\n";
|
||||
if (es.esh.count == MachO::x86_EXCEPTION_STATE64_COUNT)
|
||||
outs() << "\t esh.count x86_EXCEPTION_STATE64_COUNT\n";
|
||||
else
|
||||
outs() << "\t esh.count " << es.esh.count
|
||||
<< " (not x86_EXCEPTION_STATE64_COUNT\n";
|
||||
Print_x86_exception_state_t(es.ues.es64);
|
||||
} else {
|
||||
outs() << "\t esh.flavor " << es.esh.flavor
|
||||
<< " esh.count " << es.esh.count << "\n";
|
||||
}
|
||||
} else {
|
||||
outs() << " flavor " << flavor << " (unknown)\n";
|
||||
outs() << " count " << count << "\n";
|
||||
outs() << " state (unknown)\n";
|
||||
begin += count * sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (begin < end) {
|
||||
if (end - begin > (ptrdiff_t)sizeof(uint32_t)) {
|
||||
memcpy((char *)&flavor, begin, sizeof(uint32_t));
|
||||
begin += sizeof(uint32_t);
|
||||
} else{
|
||||
flavor = 0;
|
||||
begin = end;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
sys::swapByteOrder(flavor);
|
||||
if (end - begin > (ptrdiff_t)sizeof(uint32_t)) {
|
||||
memcpy((char *)&count, begin, sizeof(uint32_t));
|
||||
begin += sizeof(uint32_t);
|
||||
} else{
|
||||
count = 0;
|
||||
begin = end;
|
||||
}
|
||||
if (isLittleEndian != sys::IsLittleEndianHost)
|
||||
sys::swapByteOrder(count);
|
||||
outs() << " flavor " << flavor << "\n";
|
||||
outs() << " count " << count << "\n";
|
||||
outs() << " state (Unknown cputype/cpusubtype)\n";
|
||||
begin += count * sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) {
|
||||
if (dl.cmd == MachO::LC_ID_DYLIB)
|
||||
outs() << " cmd LC_ID_DYLIB\n";
|
||||
@ -3947,6 +4295,10 @@ static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t ncmds,
|
||||
} else if (Command.C.cmd == MachO::LC_ROUTINES_64) {
|
||||
MachO::routines_command_64 Rc = Obj->getRoutinesCommand64(Command);
|
||||
PrintRoutinesCommand64(Rc);
|
||||
} else if (Command.C.cmd == MachO::LC_THREAD ||
|
||||
Command.C.cmd == MachO::LC_UNIXTHREAD) {
|
||||
MachO::thread_command Tc = Obj->getThreadCommand(Command);
|
||||
PrintThreadCommand(Tc, Command.Ptr, Obj->isLittleEndian(), cputype);
|
||||
} else if (Command.C.cmd == MachO::LC_LOAD_DYLIB ||
|
||||
Command.C.cmd == MachO::LC_ID_DYLIB ||
|
||||
Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB ||
|
||||
|
Loading…
Reference in New Issue
Block a user