extern int shared;
extern void swap ( int * , int * ) ;
int main ( )
{
int a= 100 ;
swap ( & a, & shared) ;
return 0 ;
}
int shared= 1 ;
void swap ( int * a, int * b)
{
* a^ = * b^ = * a^ = * b;
}
Idx Name Size VMA LMA File off Algn
0 . text 00000027 0000000000000000 0000000000000000 00000040 2 * * 0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 . data 00000000 0000000000000000 0000000000000000 00000067 2 * * 0
CONTENTS, ALLOC, LOAD, DATA
2 . bss 00000000 0000000000000000 0000000000000000 00000067 2 * * 0
ALLOC
3 . comment 0000002 e 0000000000000000 0000000000000000 00000067 2 * * 0
CONTENTS, READONLY
4 . note. GNU- stack 00000000 0000000000000000 0000000000000000 00000095 2 * * 0
CONTENTS, READONLY
5 . eh_frame 00000038 0000000000000000 0000000000000000 00000098 2 * * 3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
Idx Name Size VMA LMA File off Algn
0 . text 0000004 a 0000000000000000 0000000000000000 00000040 2 * * 0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 . data 00000004 0000000000000000 0000000000000000 0000008 c 2 * * 2
CONTENTS, ALLOC, LOAD, DATA
2 . bss 00000000 0000000000000000 0000000000000000 00000090 2 * * 0
ALLOC
3 . comment 0000002 e 0000000000000000 0000000000000000 00000090 2 * * 0
CONTENTS, READONLY
4 . note. GNU- stack 00000000 0000000000000000 0000000000000000 000000 be 2 * * 0
CONTENTS, READONLY
5 . eh_frame 00000038 0000000000000000 0000000000000000 000000 c0 2 * * 3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
Idx Name Size VMA LMA File off Algn
0 . text 00000071 00000000004000e8 00000000004000e8 000000e8 2 * * 0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 . eh_frame 00000058 0000000000400160 0000000000400160 00000160 2 * * 3
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 . data 00000004 0000000000601000 0000000000601000 00001000 2 * * 2
CONTENTS, ALLOC, LOAD, DATA
3 . comment 0000002 d 0000000000000000 0000000000000000 00001004 2 * * 0
CONTENTS, READONLY
0000000000000000 < main> :
0 : 55 push % rbp
1 : 48 89 e5 mov % rsp, % rbp
4 : 48 83 ec 10 sub $0x10 , % rsp
8 : c7 45 fc 64 00 00 00 movl $0x64 , - 0x4 ( % rbp)
f: 48 8 d 45 fc lea - 0x4 ( % rbp) , % rax
13 : be 00 00 00 00 mov $0x0 , % esi
18 : 48 89 c7 mov % rax, % rdi
1 b: e8 00 00 00 00 callq 20 < main+ 0x20 >
20 : b8 00 00 00 00 mov $0x0 , % eax
25 : c9 leaveq
26 : c3 retq
[ wangruiqi@host- 10 - 46 - 52 - 171 LDLearn] $ objdump - d ab
00000000004000e8 < main> :
4000e8 : 55 push % rbp
4000e9 : 48 89 e5 mov % rsp, % rbp
4000 ec: 48 83 ec 10 sub $0x10 , % rsp
4000f 0 : c7 45 fc 64 00 00 00 movl $0x64 , - 0x4 ( % rbp)
4000f 7 : 48 8 d 45 fc lea - 0x4 ( % rbp) , % rax
4000f b: be 00 10 60 00 mov $0x601000 , % esi
400100 : 48 89 c7 mov % rax, % rdi
400103 : e8 07 00 00 00 callq 40010f < swap>
400108 : b8 00 00 00 00 mov $0x0 , % eax
40010 d: c9 leaveq
40010 e: c3 retq
000000000040010f < swap> :
40010f : 55 push % rbp
400110 : 48 89 e5 mov % rsp, % rbp
400113 : 48 89 7 d f8 mov % rdi, - 0x8 ( % rbp)
400117 : 48 89 75 f0 mov % rsi, - 0x10 ( % rbp)
40011 b: 48 8 b 45 f8 mov - 0x8 ( % rbp) , % rax
40011f : 8 b 10 mov ( % rax) , % edx
400121 : 48 8 b 45 f0 mov - 0x10 ( % rbp) , % rax
400125 : 8 b 08 mov ( % rax) , % ecx
400127 : 48 8 b 45 f8 mov - 0x8 ( % rbp) , % rax
40012 b: 8 b 30 mov ( % rax) , % esi
40012 d: 48 8 b 45 f0 mov - 0x10 ( % rbp) , % rax
400131 : 8 b 00 mov ( % rax) , % eax
400133 : 31 c6 xor % eax, % esi
400135 : 48 8 b 45 f8 mov - 0x8 ( % rbp) , % rax
400139 : 89 30 mov % esi, ( % rax)
40013 b: 48 8 b 45 f8 mov - 0x8 ( % rbp) , % rax
40013f : 8 b 00 mov ( % rax) , % eax
400141 : 31 c1 xor % eax, % ecx
400143 : 48 8 b 45 f0 mov - 0x10 ( % rbp) , % rax
400147 : 89 08 mov % ecx, ( % rax)
400149 : 48 8 b 45 f0 mov - 0x10 ( % rbp) , % rax
40014 d: 8 b 00 mov ( % rax) , % eax
40014f : 31 c2 xor % eax, % edx
400151 : 48 8 b 45 f8 mov - 0x8 ( % rbp) , % rax
400155 : 89 10 mov % edx, ( % rax)
400157 : 5 d pop % rbp
400158 : c3 retq
RELOCATION RECORDS FOR [ . text] :
OFFSET TYPE VALUE
0000000000000014 R_X86_64_32 shared
000000000000001 c R_X86_64_PC32 swap- 0x0000000000000004
RELOCATION RECORDS FOR [ . eh_frame] :
OFFSET TYPE VALUE
0000000000000020 R_X86_64_PC32 . text
Symbol table '.symtab' contains 11 entries:
Num: Value Size Type Bind Vis Ndx Name
0 : 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1 : 0000000000000000 0 FILE LOCAL DEFAULT ABS a. c
2 : 0000000000000000 0 SECTION LOCAL DEFAULT 1
3 : 0000000000000000 0 SECTION LOCAL DEFAULT 3
4 : 0000000000000000 0 SECTION LOCAL DEFAULT 4
5 : 0000000000000000 0 SECTION LOCAL DEFAULT 6
6 : 0000000000000000 0 SECTION LOCAL DEFAULT 7
7 : 0000000000000000 0 SECTION LOCAL DEFAULT 5
8 : 0000000000000000 39 FUNC GLOBAL DEFAULT 1 main
9 : 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND shared
10 : 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND swap