physical-computation / sunflower-embedded-system-emulator

Sunflower Full-System Hardware Emulator and Physical System Simulator for Sensor-Driven Systems. Built-in architecture modeling of Hitachi SH (j-core), RISC-V, and more.
http://sflr.org
BSD 3-Clause "New" or "Revised" License
23 stars 215 forks source link

srecl cannot handle filenames with hyphen #158

Closed jan-heck closed 4 years ago

jan-heck commented 4 years ago

Describe the bug srecl cannot handle filenames with hyphen, and sunflower gives an invalid command error.

To Reproduce Steps to reproduce the behavior: To demonstrate, take a working binary and copy it to a filename with a hyphen in it. I first run sf to load the working one, and then again with the copied and renamed version, and get an invalid command in the latter case.

~/git/sflr/benchmarks/source/riscv_newton-raphson l
total 76K             hidden objects: 1
-rw-r--r-- 1 arch  163 Jan 12 16:08 init.S
-rwxr-xr-x 1 arch 1.1K Jan 13 08:21 Makefile*
-rw-r--r-- 1 arch 1.8K Jan 12 21:32 newton_raphson.c
-rw-r--r-- 1 arch  58K Jan 25 17:24 newton_raphson.s
-rwxr-xr-x 1 arch   74 Jan 12 21:32 run.m*
~/git/sflr/benchmarks/source/riscv_newton-raphson make
/home/arch/git/sflr/tools/bin/riscv32-elf-gcc -E -o init.i init.S; /home/arch/git/sflr/tools/bin/uncertain-riscv32-elf-as init.i -o init.o
/home/arch/git/sflr/tools/bin/uncertain-riscv32-elf-as --march=rv32ifdxun -g -o newton_raphson.o -c newton_raphson.s
/home/arch/git/sflr/tools/bin/uncertain-riscv32-elf-ld -Ttext 0x08004000 -L/home/arch/git/sflr/tools/tools-lib/riscv init.o newton_raphson.o  -o newton_raphson.out -luncertain -lprintf -lc -lgloss -lgcc -lm
/home/arch/git/sflr/tools/utilities/fix-uncertain-binary.py newton_raphson.out /home/arch/git/sflr/tools/bin/uncertain-riscv32-elf-readelf
/home/arch/git/sflr/tools/bin/uncertain-riscv32-elf-objcopy -O srec newton_raphson.out newton_raphson.sr
~/git/sflr/benchmarks/source/riscv_newton-raphson cp newton_raphson.sr filename-with-hyphens.sr
~/git/sflr/benchmarks/source/riscv_newton-raphson sf
Initialized random number generator with seed -61995312...

Sunflower 1.1 (build 01-13-2020-12:36:41-arch@nbpb-Linux)
Authored, 1999-2018: Phillip Stanley-Marbell <phillip.stanleymarbell@gmail.com>. 20018-onwards: See CONTRIBUTORS.TXT.
This software is provided with ABSOLUTELY NO WARRANTY. Read LICENSE.txt

New node created with node ID 0

[ID=0 of 1][PC=0x8000000][3.3E+00V, 6.0E+01MHz] srecl newton_raphson.sr
Loading S-RECORD to memory at address 0x8004000
[M] Done.
[ID=0 of 1][PC=0x8004000][3.3E+00V, 6.0E+01MHz] run
args = [], argc = 0
R4 = [0x00000000], R5 = [0x08fffef0]
Running...

[ID=0 of 1][PC=0x8004000][3.3E+00V, 6.0E+01MHz] q

    Exiting: Exiting as per user's request.
    Writing all node information to sunflower.out

~/git/sflr/benchmarks/source/riscv_newton-raphson sf
Initialized random number generator with seed -1762406596...

Sunflower 1.1 (build 01-13-2020-12:36:41-arch@nbpb-Linux)
Authored, 1999-2018: Phillip Stanley-Marbell <phillip.stanleymarbell@gmail.com>. 20018-onwards: See CONTRIBUTORS.TXT.
This software is provided with ABSOLUTELY NO WARRANTY. Read LICENSE.txt

New node created with node ID 0

[ID=0 of 1][PC=0x8000000][3.3E+00V, 6.0E+01MHz] srecl filename-with-hyphens.sr
Error: Invalid command! (for superH)
[ID=0 of 1][PC=0x8000000][3.3E+00V, 6.0E+01MHz] ^C

Expected behavior Should handle filename with hyphen.

Screenshots (see terminal log above)

Host OS (please complete the following information):

You local changes (please complete the following information):

Additional context

phillipstanleymarbell commented 4 years ago

Because you can type inline assembly language for interpretation at the command line, many tokens such as @ and - are reserved. To enter a string which has reserved tokens at any point, you should put the name in quotes:

[ID=0 of 1][PC=0x8000000][3.3E+00V, 6.0E+01MHz] srecl "filename-with-hyphens.sr"
Loading S-RECORD to memory at address 0x8004000
[M] Done.
[ID=0 of 1][PC=0x8004000][3.3E+00V, 6.0E+01MHz] 
jan-heck commented 4 years ago

I see -- I copied over a run.m which didn't do so and didn't think of adding it. It makes perfect sense that there are illegal characters for filenames, but it took me quite some time to track it down (I was looking at other possible causes). Perhaps the invalid command error could show what it considers to be the invalid command (like e.g. bash does if you type in a misspelt command), which would have made the cause of the problem immediately obvious.

Thanks for pointing out the solution, I'll change my script.