简体   繁体   English

Mac OS X,如何为ARM编译.c文件并在之后反汇编?

[英]Mac OS X, how to compile a .c file for ARM and disassemble it after?

I want to disassemble a simple .c file: 我想反汇编一个简单的.c文件:

#define UPPER 15 
const int lower = 12;
int sum = 0;

int main(void) { 
  int i;
  for(i = lower; i < UPPER; i++) 
  { 
    sum += i;
  }
return sum;
}

To get the assemblercode for ARM CPUs on my Mac Mini 10.8.3. 在Mac Mini 10.8.3上获取ARM CPU的汇编代码。 There fore i am stuck at: 我被困在这里:

  • How do i create the ARM executable for the above .c file? 如何为上述.c文件创建ARM可执行文件?
  • How to disassemble the executable after that? 之后如何反汇编可执行文件?

Thanks for your Help! 谢谢你的帮助!

To compile (assuming the target is iOS 6.0): 进行编译 (假设目标是iOS 6.0):

xcrun -sdk iphoneos c++ -arch armv7 -marm -march=armv7-a -miphoneos-version-min=6.0 -g -O3 <any other options ...>

To disassemble: 拆卸:

otool -tdv <your binary>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM