jserv / full-stack-hello

minimal instruction set and assembler/compiler for "Hello World" execution
Other
114 stars 49 forks source link

ELF save/load support #36

Closed pakls closed 7 years ago

pakls commented 7 years ago

Hi, All, I am implementing the support of this. :)

Currently, the instruction set implementation is host specific. That is, if current host is 64 bits, then the in VM and everything will be 64 bits, and vice versa.

jserv commented 7 years ago

To clarify the width of register file, I would suggest to restrict all registers to 32-bit by default.

jserv commented 7 years ago

Thank @pakls for implementing ELF support, which enables this VM embeddable to existing applications.

I just try to assemble a simple program as following instructions:

$ ./as_exec -w tests/hello.s 
$  ./as_exec -x tests/hello.o 
Hello World

It works as I expected! However, it looks weird when I check its information via file:

$ file tests/hello.o 
tests/hello.o: ELF 64-bit LSB executable, no machine, version 1 (SYSV), statically linked, interpreter *empty*, corrupted section header size

Can we add extra information while generating ELF files?

jserv commented 7 years ago

In addition, we shall update README.md to reflect recent changes.

jserv commented 7 years ago

Refer to pull request #37 .

pakls commented 7 years ago

Missed the comments here: I would suggest to restrict all registers to 32-bit by default.

For the register width issue, current source code uses 32-bit when compiled by 32-bit compiler. With 64-bit GCC, it becomes 64-bit but can be overridden by -m32 option.

'file' or 'objdump' should be able to show 32/64-bit successfully. Per test, they both work, too.

pakls commented 7 years ago

The message "corrupted section header size" is due to the tool incorrectly considers section size 0 as error.

In our case, '0' is simply not implemented. The implementation is not added because it is not needed yet. It would be needed when we plan to support section. Currently, segments are enough as the vm internal structure is fixed to 3 segments and with fixed purpose.

pakls commented 7 years ago

"no machine" is correct as the full-stack-vm is not recognized by the tool. So I filled no-machine to ELF file header for now.

pakls commented 7 years ago

I will update README.md later.

jserv commented 7 years ago

Related: #32 (new name for ISA)

pakls commented 7 years ago

Add more info to ELF when needed. Close for now.