iOS处理器的小端模式
Tags
iOS
Date
Jun 15, 2020
iOS 设备的处理器是基于 ARM 架构的,采用小端模式(低字节放低位)读取数据的。
notion image
可以在一个ViewController里断点实验,可以看到
  • 这个vc的地址是0x7f8974f0c830
  • 这个vc的第一个8字节是0x000000010a9a2390,在内存中的显示为90 23 9a 0a 01 00 00 00
    • 这个8字节表示的是vc的isa,即[ViewController class]的地址
  • 这个vc的第二个8字节是0x00007f8974d18750,在内存中的显示为50 87 d1 74 89 7f 00 00
    • 这个8字节表示是vc.view
(lldb) po self
<ViewController: 0x7f8974f0c830>

(lldb) x self
0x7f8974f0c830: 90 23 9a 0a 01 00 00 00 00 00 00 00 00 00 00 00  .#..............
0x7f8974f0c840: 00 00 00 00 00 00 00 00 50 87 d1 74 89 7f 00 00  ........P..t....
(lldb) x/4 self
0x7f8974f0c830: 0x000000010a9a2390 0x0000000000000000
0x7f8974f0c840: 0x0000000000000000 0x00007f8974d18750

(lldb) po 0x000000010a9a2390
ViewController
(lldb) x 0x000000010a9a2390
0x10a9a2390: b8 23 9a 0a 01 00 00 00 d0 f7 7d 89 ff 7f 00 00  .#........}.....
0x10a9a23a0: 00 d2 82 75 89 7f 00 00 7f 00 00 00 5c 83 32 00  ...u........\.2.
(lldb) x self.class
0x10a9a2390: b8 23 9a 0a 01 00 00 00 d0 f7 7d 89 ff 7f 00 00  .#........}.....
0x10a9a23a0: 00 d2 82 75 89 7f 00 00 7f 00 00 00 5c 83 32 00  ...u........\.2.

(lldb) po 0x00007f8974d18750
<UIView: 0x7f8974d18750; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x6000012c92e0>>
(lldb) x 0x00007f8974d18750
0x7f8974d18750: 58 f9 80 89 ff 7f 00 00 00 00 00 00 00 00 00 00  X...............
0x7f8974d18760: 00 00 00 00 00 00 00 00 40 08 7f 02 00 60 00 00  ........@....`..
(lldb) x self.view
0x7f8974d18750: 58 f9 80 89 ff 7f 00 00 00 00 00 00 00 00 00 00  X...............
0x7f8974d18760: 00 00 00 00 00 00 00 00 40 08 7f 02 00 60 00 00  [email protected]`..
 

Loading Comments...