jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 160 forks source link

Use Dynasm to implement the test case #9

Closed gapry closed 7 years ago

gapry commented 8 years ago

I can't load the PC value which is a memory location to a general purpose register r0.

It is my current implementation jit-arm.dasm The line 16 is that instruction, ldr r0, [pc, #12]

All the instruction will translate into a unsigned integer array which contain all the machine code. //|.actionlist actions static const unsigned int actions[6] = { 0xe59f000c, 0xe5901000, 0xe2811009, 0xe5801000, 0xe1a0f00e, 0x00000000 };

It is as same as tests/jit.c Hence, I don't know why it occurs the following error as it executes the instruction, ldr r0, [pc, #12]

lua ./dynasm.lua -o jit-arm.h jit-arm.dasc arm-linux-gnueabihf-gcc -Wall -std=gnu99 -I. -o jit-arm -DJIT=\"jit-arm.h\" dynasm-driver.c qemu-arm -L /usr/arm-linux-gnueabihf jit-arm qemu: uncaught target signal 11 (Segmentation fault) - core dumped make: *** [run-jit-arm] Segmentation fault (core dumped)

Any suggestion ? (BTW, if I change PC to SP, everything is ok)

jserv commented 8 years ago

@gapry : Can you take a look at elf32() which manipulates stack pointer appropriately?

gapry commented 8 years ago

@jserv ok !

jserv commented 7 years ago

Not a valid issue anymore. We have implemented ELF writer and jitter, which enable JIT/AOT compilation.