0 Replies Latest reply: Nov 14, 2012 12:22 PM by banxian
banxian Level 1 Level 1 (0 points)

this is a very lite demo, taked from my complete hook project.

 

.syntax unified

.macro .donothing
.text
.private_extern $0
.globl $0
.align 2
.arm
$0:
    movw    r0, :lower16:2f-(1f+8))
    movt    r0, :upper16:2f-(1f+8))
1:
    add     r0, pc, r0
    blx     lr
.cstring
2:
    .asciz $1
.endm

.donothing _getstr, "He llo wor ld !\n"

 

I added the .s file into xcode, and call it from main.cpp like this

 

#include <stdio.h>

extern "C" char* getstr();

int main(int argc, char* argv[]) {
    fprintf(stderr, "%s", getstr());
    return 0;
}

 

only "Helloworld!\n" printed in xcode's lldb console. all space in $1 removed during macro expanding. surely *.o file already have striped version for my string (with otool).

I am using XCode 4.3.3, I think it's totally a bug, not a design.

because the same x64 version working fine.

 

 

.macro .donothing
.text
.private_extern $0
.globl $0
.align 2
$0:
    leaq     1f(%rip), %rax
    ret
.cstring
1:
    .asciz $1
.endm

.donothing _getstr, "He llo wor ld !\n"

 

 

back to the arm clang/llvm as, I found instruction like

adr r12, label

just let assembler (libexec/arm/as) crash without any output.

ldr r12, =0x8

can crash assemberl sometimes too.


iPhone 4S, iOS 5.1.1, XCode 4.3.3