Diassemblieren

Aus C und Assembler mit Raspberry

Diassemblieren

-> objdump -s -d HelloWorld.o > HelloWorld.diassem


Hello.o: file format elf64-littleaarch64

Contents of section .text:

0000 200080d2 e1000058 a20180d2 080880d2   ......X........
0010 010000d4 000080d2 a80b80d2 010000d4  ................
0020 00000000 00000000                    ........        

Contents of section .data:

0000 48656c6c 6f20576f 726c6421 0a        Hello World!.   

Disassembly of section .text:

0000000000000000 <_start>:

  0:	d2800020 	mov	x0, #0x1                   	// #1
  4:	580000e1 	ldr	x1, 20 <_start+0x20>
  8:	d28001a2 	mov	x2, #0xd                   	// #13
  c:	d2800808 	mov	x8, #0x40                  	// #64
 10:	d4000001 	svc	#0x0
 14:	d2800000 	mov	x0, #0x0                   	// #0
 18:	d2800ba8 	mov	x8, #0x5d                  	// #93
 1c:	d4000001 	svc	#0x0

...


negative Zahlen

-> Beispiel: 5 + -3

 3 in 1 byte is 0x03 or 0000 0011.
 Inverting the bits is
 1111 1100
 Add 1 to get
 1111 1101 = 0xFD
 Now add
 5 + 0xFD = 0x102 = 2

movadd.o: file format elf64-littleaarch64

Contents of section .text:

0000 001980d2 812580d2 0200018b a00080d2  .....%..........
0010 41008092 0200018b 000080d2 a80b80d2  A...............
0020 010000d4                             ....            

Disassembly of section .text:

0000000000000000 <_start>:

  0:	d2801900 	mov	x0, #0xc8                  	// #200
  4:	d2802581 	mov	x1, #0x12c                 	// #300
  8:	8b010002 	add	x2, x0, x1
  c:	d28000a0 	mov	x0, #0x5                   	// #5
 10:	92800041 	mov	x1, #0xfffffffffffffffd    	// #-3
 14:	8b010002 	add	x2, x0, x1
 18:	d2800000 	mov	x0, #0x0                   	// #0
 1c:	d2800ba8 	mov	x8, #0x5d                  	// #93
 20:	d4000001 	svc	#0x0