21,459
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
typedef struct {
unsigned int one:1;
unsigned int two:3;
unsigned int three:10;
unsigned int four:5;
unsigned int :2;
unsigned int five:8;
unsigned int six:8;
} demo_type;
int main()
{
demo_type s = {1,5,513,17,129,0x81};
printf("sizeof demo_type = %u\n",sizeof(demo_type));
printf("values: s=%u,%u,%u,%u,%u,%u\n",s.one,s.two,s.three,s.four,s.five,s.six);
return 0;
}
bit_field: file format elf32-i386
Disassembly of section .init:
08048294 <_init>:
8048294: 55 push %ebp #栈底入栈,保存栈底
8048295: 89 e5 mov %esp,%ebp #用栈顶做新栈底
8048297: 53 push %ebx #基地址入栈
8048298: 83 ec 04 sub $0x4,%esp #栈顶向下增4,分配4字节
804829b: e8 00 00 00 00 call 80482a0 <_init+0xc> #跳转到下4字节
80482a0: 5b pop %ebx #基地址出栈
80482a1: 81 c3 54 1d 00 00 add $0x1d54,%ebx #此处不理解,是将基地址做什么操作?作用?
80482a7: 8b 93 fc ff ff ff mov -0x4(%ebx),%edx #%ebx偏移4送入%edx
80482ad: 85 d2 test %edx,%edx #测试是否相等
80482af: 74 05 je 80482b6 <_init+0x22> #相等则跳转
80482b1: e8 1e 00 00 00 call 80482d4 <__gmon_start__@plt>
80482b6: e8 e5 00 00 00 call 80483a0 <frame_dummy>
80482bb: e8 90 02 00 00 call 8048550 <__do_global_ctors_aux>
80482c0: 58 pop %eax
80482c1: 5b pop %ebx
80482c2: c9 leave
80482c3: c3 ret
Disassembly of section .plt:
080482c4 <__gmon_start__@plt-0x10>:
80482c4: ff 35 f8 9f 04 08 pushl 0x8049ff8
80482ca: ff 25 fc 9f 04 08 jmp *0x8049ffc
80482d0: 00 00 add %al,(%eax)
...
080482d4 <__gmon_start__@plt>:
80482d4: ff 25 00 a0 04 08 jmp *0x804a000
80482da: 68 00 00 00 00 push $0x0
80482df: e9 e0 ff ff ff jmp 80482c4 <_init+0x30>
080482e4 <__libc_start_main@plt>:
80482e4: ff 25 04 a0 04 08 jmp *0x804a004
80482ea: 68 08 00 00 00 push $0x8
80482ef: e9 d0 ff ff ff jmp 80482c4 <_init+0x30>
080482f4 <printf@plt>:
80482f4: ff 25 08 a0 04 08 jmp *0x804a008
80482fa: 68 10 00 00 00 push $0x10
80482ff: e9 c0 ff ff ff jmp 80482c4 <_init+0x30>