cornell-brg / pydgin

A (Py)thon (D)SL for (G)enerating (In)struction set simulators.
BSD 3-Clause "New" or "Revised" License
165 stars 29 forks source link

Cross compiling and running asm_tests #19

Closed salmanarif closed 9 years ago

salmanarif commented 9 years ago

Hi,

I am tyring to cross-compile the different test files in the arm/asm_tests directory, and then simulate them using python arm-sim.py <path_to_elf_file>.

For example, when I run the above command with the compiled version of adc_00.S, I get the following output, after which the program gets stuck in an infinite loop and must be manually exited:

sparse memory size 400 addr mask 3ff block mask fffffc00
XXX 3221209129
WARNING: syscall not implemented: 0

I have the gcc-arm-linux-gnueabi cross-compiler installed.

I would appreciate it if you could point out where I could be going wrong, or if the test files cannot be used in this manner.

Thank you!

dmlockhart commented 9 years ago

Unfortunately we've haven't done a great job keeping track of the state of these tests. The files in arm/asm_tests are meant to be automatically compiled, executed, and verified using py.test and the test driver arm_asm_tests.py, however, these aren't currently working for me.

However, I am able to compile and run the tests directly (as you are trying to do) successfully. The following is my setup:

  $ arm-unknown-linux-uclibcgnueabi-gcc -nostdlib ../arm/asm_tests/adc-00.S -o /tmp/a.out
  $ python ../arm/arm-sim.py --debug insts,mem,regdump,syscalls /tmp/a.out

NOTE: Using sparse storage
sparse memory size 400 addr mask 3ff block mask fffffc00
XXX 3221209160
  8094 e3a02001 mov      0       
0 :00000000 1 :00000001 2 :00000001 3 :00000000 
4 :00000000 5 :00000000 6 :00000000 7 :00000000 
8 :00000000 9 :00000000 10:00000000 11:00000000 
12:00000000 13:bfffc000 14:00000000 15:00000000 
----
  8098 e3a03001 mov      1       
0 :00000000 1 :00000001 2 :00000001 3 :00000001 
4 :00000000 5 :00000000 6 :00000000 7 :00000000 
8 :00000000 9 :00000000 10:00000000 11:00000000 
12:00000000 13:bfffc000 14:00000000 15:00000000 
----
  809c e3a04000 mov      2       
0 :00000000 1 :00000001 2 :00000001 3 :00000001 
4 :00000000 5 :00000000 6 :00000000 7 :00000000 
8 :00000000 9 :00000000 10:00000000 11:00000000 
12:00000000 13:bfffc000 14:00000000 15:00000000 
----
  80a0 e0a24003 adc      3       
0 :00000000 1 :00000001 2 :00000001 3 :00000001 
4 :00000002 5 :00000000 6 :00000000 7 :00000000 
8 :00000000 9 :00000000 10:00000000 11:00000000 
12:00000000 13:bfffc000 14:00000000 15:00000000 
----
  80a4 e3a07001 mov      4       
0 :00000000 1 :00000001 2 :00000001 3 :00000001 
4 :00000002 5 :00000000 6 :00000000 7 :00000001 
8 :00000000 9 :00000000 10:00000000 11:00000000 
12:00000000 13:bfffc000 14:00000000 15:00000000 
----
  80a8 ef000000 swi      5        syscall_exit( status=0 )
 retval=0 errno=0

0 :00000000 1 :00000001 2 :00000001 3 :00000001 
4 :00000002 5 :00000000 6 :00000000 7 :00000001 
8 :00000000 9 :00000000 10:00000000 11:00000000 
12:00000000 13:bfffc000 14:00000000 15:00000000 
----
DONE! Status = 0

Make sure you pass the -nostdlib flag! If that still isn't working, it may be because your cross compiler is using glibc. We only explicitly support newlib cross compiler based flows; I'm not sure that should effect these assembly tests but I wouldn't be surprised if that is causing a problem.

salmanarif commented 9 years ago

Thank you for the prompt reply! I am now able to compile and run the tests using these instructions. The -nostdlib flag was the key to getting it work.