Dmitry Telenkov 9 timmar sedan
förälder
incheckning
098ff9c288
9 ändrade filer med 232 tillägg och 0 borttagningar
  1. 118 0
      asm/ld/d.txt
  2. BIN
      asm/ld/main.exe
  3. BIN
      asm/ld/main.o
  4. 19 0
      asm/ld/main.s
  5. 22 0
      asm/ld/test1.s
  6. 22 0
      asm/ld/test2.s
  7. 11 0
      asm/print.asm
  8. 20 0
      asm/test_10.asm
  9. 20 0
      asm/test_11.s

+ 118 - 0
asm/ld/d.txt

@@ -0,0 +1,118 @@
+
+main.exe:     file format elf64-x86-64
+
+
+Disassembly of section .init:
+
+0000000000001000 <_init>:
+    1000:	48 83 ec 08          	sub    $0x8,%rsp
+    1004:	48 8b 05 c5 2f 00 00 	mov    0x2fc5(%rip),%rax        # 3fd0 <__gmon_start__@Base>
+    100b:	48 85 c0             	test   %rax,%rax
+    100e:	74 02                	je     1012 <_init+0x12>
+    1010:	ff d0                	call   *%rax
+    1012:	48 83 c4 08          	add    $0x8,%rsp
+    1016:	c3                   	ret
+
+Disassembly of section .plt:
+
+0000000000001020 <.plt>:
+    1020:	ff 35 ca 2f 00 00    	push   0x2fca(%rip)        # 3ff0 <_GLOBAL_OFFSET_TABLE_+0x8>
+    1026:	ff 25 cc 2f 00 00    	jmp    *0x2fcc(%rip)        # 3ff8 <_GLOBAL_OFFSET_TABLE_+0x10>
+    102c:	0f 1f 40 00          	nopl   0x0(%rax)
+
+Disassembly of section .plt.got:
+
+0000000000001030 <__cxa_finalize@plt>:
+    1030:	ff 25 aa 2f 00 00    	jmp    *0x2faa(%rip)        # 3fe0 <__cxa_finalize@GLIBC_2.2.5>
+    1036:	66 90                	xchg   %ax,%ax
+
+Disassembly of section .text:
+
+0000000000001040 <_start>:
+    1040:	31 ed                	xor    %ebp,%ebp
+    1042:	49 89 d1             	mov    %rdx,%r9
+    1045:	5e                   	pop    %rsi
+    1046:	48 89 e2             	mov    %rsp,%rdx
+    1049:	48 83 e4 f0          	and    $0xfffffffffffffff0,%rsp
+    104d:	50                   	push   %rax
+    104e:	54                   	push   %rsp
+    104f:	45 31 c0             	xor    %r8d,%r8d
+    1052:	31 c9                	xor    %ecx,%ecx
+    1054:	48 8d 3d ce 00 00 00 	lea    0xce(%rip),%rdi        # 1129 <main>
+    105b:	ff 15 5f 2f 00 00    	call   *0x2f5f(%rip)        # 3fc0 <__libc_start_main@GLIBC_2.34>
+    1061:	f4                   	hlt
+    1062:	66 2e 0f 1f 84 00 00 	cs nopw 0x0(%rax,%rax,1)
+    1069:	00 00 00 
+    106c:	0f 1f 40 00          	nopl   0x0(%rax)
+
+0000000000001070 <deregister_tm_clones>:
+    1070:	48 8d 3d a1 2f 00 00 	lea    0x2fa1(%rip),%rdi        # 4018 <__TMC_END__>
+    1077:	48 8d 05 9a 2f 00 00 	lea    0x2f9a(%rip),%rax        # 4018 <__TMC_END__>
+    107e:	48 39 f8             	cmp    %rdi,%rax
+    1081:	74 15                	je     1098 <deregister_tm_clones+0x28>
+    1083:	48 8b 05 3e 2f 00 00 	mov    0x2f3e(%rip),%rax        # 3fc8 <_ITM_deregisterTMCloneTable@Base>
+    108a:	48 85 c0             	test   %rax,%rax
+    108d:	74 09                	je     1098 <deregister_tm_clones+0x28>
+    108f:	ff e0                	jmp    *%rax
+    1091:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+    1098:	c3                   	ret
+    1099:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+
+00000000000010a0 <register_tm_clones>:
+    10a0:	48 8d 3d 71 2f 00 00 	lea    0x2f71(%rip),%rdi        # 4018 <__TMC_END__>
+    10a7:	48 8d 35 6a 2f 00 00 	lea    0x2f6a(%rip),%rsi        # 4018 <__TMC_END__>
+    10ae:	48 29 fe             	sub    %rdi,%rsi
+    10b1:	48 89 f0             	mov    %rsi,%rax
+    10b4:	48 c1 ee 3f          	shr    $0x3f,%rsi
+    10b8:	48 c1 f8 03          	sar    $0x3,%rax
+    10bc:	48 01 c6             	add    %rax,%rsi
+    10bf:	48 d1 fe             	sar    %rsi
+    10c2:	74 14                	je     10d8 <register_tm_clones+0x38>
+    10c4:	48 8b 05 0d 2f 00 00 	mov    0x2f0d(%rip),%rax        # 3fd8 <_ITM_registerTMCloneTable@Base>
+    10cb:	48 85 c0             	test   %rax,%rax
+    10ce:	74 08                	je     10d8 <register_tm_clones+0x38>
+    10d0:	ff e0                	jmp    *%rax
+    10d2:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
+    10d8:	c3                   	ret
+    10d9:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+
+00000000000010e0 <__do_global_dtors_aux>:
+    10e0:	f3 0f 1e fa          	endbr64
+    10e4:	80 3d 2a 2f 00 00 00 	cmpb   $0x0,0x2f2a(%rip)        # 4015 <completed.0>
+    10eb:	75 2b                	jne    1118 <__do_global_dtors_aux+0x38>
+    10ed:	55                   	push   %rbp
+    10ee:	48 83 3d ea 2e 00 00 	cmpq   $0x0,0x2eea(%rip)        # 3fe0 <__cxa_finalize@GLIBC_2.2.5>
+    10f5:	00 
+    10f6:	48 89 e5             	mov    %rsp,%rbp
+    10f9:	74 0c                	je     1107 <__do_global_dtors_aux+0x27>
+    10fb:	48 8b 3d 06 2f 00 00 	mov    0x2f06(%rip),%rdi        # 4008 <__dso_handle>
+    1102:	e8 29 ff ff ff       	call   1030 <__cxa_finalize@plt>
+    1107:	e8 64 ff ff ff       	call   1070 <deregister_tm_clones>
+    110c:	c6 05 02 2f 00 00 01 	movb   $0x1,0x2f02(%rip)        # 4015 <completed.0>
+    1113:	5d                   	pop    %rbp
+    1114:	c3                   	ret
+    1115:	0f 1f 00             	nopl   (%rax)
+    1118:	c3                   	ret
+    1119:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+
+0000000000001120 <frame_dummy>:
+    1120:	f3 0f 1e fa          	endbr64
+    1124:	e9 77 ff ff ff       	jmp    10a0 <register_tm_clones>
+
+0000000000001129 <main>:
+    1129:	48 89 e5             	mov    %rsp,%rbp
+    112c:	48 c7 c0 01 00 00 00 	mov    $0x1,%rax
+    1133:	48 c7 c7 01 00 00 00 	mov    $0x1,%rdi
+    113a:	48 8d 35 cf 2e 00 00 	lea    0x2ecf(%rip),%rsi        # 4010 <str>
+    1141:	48 c7 c2 05 00 00 00 	mov    $0x5,%rdx
+    1148:	0f 05                	syscall
+    114a:	48 89 ec             	mov    %rbp,%rsp
+    114d:	48 c7 c0 00 00 00 00 	mov    $0x0,%rax
+    1154:	c3                   	ret
+
+Disassembly of section .fini:
+
+0000000000001158 <_fini>:
+    1158:	48 83 ec 08          	sub    $0x8,%rsp
+    115c:	48 83 c4 08          	add    $0x8,%rsp
+    1160:	c3                   	ret

BIN
asm/ld/main.exe


BIN
asm/ld/main.o


+ 19 - 0
asm/ld/main.s

@@ -0,0 +1,19 @@
+    .file "main.s"
+    .data
+str:
+    .ascii "test\n"
+    .text
+    .globl main
+main:
+    movq %rsp, %rbp
+
+    movq $1, %rax
+    movq $1, %rdi
+    leaq str(%rip), %rsi
+    movq $5, %rdx
+    syscall
+
+    movq %rbp, %rsp
+
+    movq $0, %rax
+    ret

+ 22 - 0
asm/ld/test1.s

@@ -0,0 +1,22 @@
+    .file "test1.s"
+    .data
+str:
+    .ascii "test1\n"
+    .text
+    .global test1
+
+test1:
+    movq %rsp, %rbp
+
+    movq $1, %rax
+    movq $1, %rdi
+    leaq str(%rip), %rsi
+    movq $6, %rdx
+    syscall
+
+    movq %rbp, %rsp
+
+    //exit
+    movq $60, %rax
+    movq $0, %rdi
+    syscall

+ 22 - 0
asm/ld/test2.s

@@ -0,0 +1,22 @@
+    .file "test2.s"
+    .data
+str:
+    .ascii "test2\n"
+    .text
+    .global test2
+
+test2:
+    movq %rsp, %rbp
+
+    movq $1, %rax
+    movq $1, %rdi
+    leaq str(%rip), %rsi
+    movq $6, %rdx
+    syscall
+
+    movq %rbp, %rsp
+
+    // exit
+    movq $60, %rax
+    movq $0, %rdi
+    syscall

+ 11 - 0
asm/print.asm

@@ -0,0 +1,11 @@
+    .file "print.asm"
+    .text
+    .global print
+
+print:
+    movq $1, %rax
+    movq $1, %rdi
+    leaq str(%rip), %rsi
+    movq $5, %rdx
+    syscall
+    ret

+ 20 - 0
asm/test_10.asm

@@ -0,0 +1,20 @@
+    .file "test_10.asm"
+    .data
+    .global str
+str:
+    .ascii "test\n"
+    .text
+    .global _start
+
+_start:
+    movq %rsp, %rbp
+
+    call print
+
+    movq %rbp, %rsp
+
+    // exit
+    movq $60, %rax
+    movq $0, %rdi
+    syscall
+

+ 20 - 0
asm/test_11.s

@@ -0,0 +1,20 @@
+    .file "test_11.as"
+    .text
+    .data
+str:
+    .ascii "test\n"
+    .text
+    .globl main
+main:
+    endbr64
+    movq %rsp, %rbp
+
+    movq $0, %rax
+    movq $1, %rdi
+    leaq str(%rip), %rsi
+    movq $5, %rdx
+    callq write
+
+    movq %rbp, %rsp
+    movl $0, %eax
+    ret