Page 1 of 1

Disassembly bug with LDR addresses

PostPosted: Mon Apr 18, 2016 4:36 pm
by Siguza
jtool and disarm both disassemble LDR addresses to 1/4 of what they should be.

bash$ cat one.S
_main:
ldr w0, #4
bash$ aarch64-elf-as -o one.o one.S
bash$ aarch64-elf-objcopy -O binary one.o one.b
bash$ disarm one.b
0x00000000 0x18000020 LDR W0, #1

bash$ cat two.S
.section __TEXT,__text,regular,pure_instructions
.ios_version_min 9, 3
.globl _main
.align 2
_main:
ldr w0, #4
bash$ xcrun -sdk iphoneos as -arch arm64 -o two.o two.S
bash$ xcrun -sdk iphoneos ld -arch arm64 -ios_version_min 9.3 -L$iSDK/usr/lib -lSystem -o two two.o
bash$ jtool -d two
Warning: companion file ./two.ARM64.58E3340D-6AC2-3250-8EA2-341DF970B78B not found
Disassembling from file offset 0x7fb4, Address 0x100007fb4
; // function #1
_main:
100007fb4 LDR W0, #1 ; X0 = *(100007fb8) = 1 ... ?
Done 1

Re: Disassembly bug with LDR addresses

PostPosted: Mon Apr 18, 2016 8:54 pm
by morpheus
Thank you! Noted and fixed. Needed a <<2 there.

Reason why jtool/disarm report same is because they are both compiled with same library.

Updates to both coming soon

J