-
Notifications
You must be signed in to change notification settings - Fork 2
How to Add New Architectures #1
Description
This issue describes the general steps of adding a new architecture into the project. I will use x86-64 as the example since it was the last one added as of now.
-
Get qiling's rootfs for the architecture and add it to this repo, e.g., https://github.com/assembliss/webassembliss/tree/main/webassembliss/rootfs/x8664_linux
-
create user workspace (i.e.,
userprogramsfolder) inside rootfs, e.g., https://github.com/assembliss/webassembliss/tree/main/webassembliss/rootfs/x8664_linux/userprograms -
install required tooling in dockerfile, e.g.,
Lines 22 to 23 in ecf9695
# x8664 linux toolchain (assemble/link x8664 linux assembly code) make gcc-x86-64-linux-gnu\ -
create an editor template for the architecture, e.g., https://github.com/assembliss/webassembliss/blob/main/webassembliss/templates/x8664_linux.html.j2
- if needed, also include the status flags, e.g.,
webassembliss/webassembliss/templates/x8664_linux.html.j2
Lines 29 to 36 in ecf9695
{% block statusFlags %} <th>Status Flags</th> {# The ID should be formatted as "<flag name>Flag" so the tracing logic can update values without changes. #} <td>SF: <span id="sfFlag">⭕</span></td> <td>ZF: <span id="zfFlag">⭕</span></td> <td>CF: <span id="cfFlag">⭕</span></td> <td>OF: <span id="ofFlag">⭕</span></td> {% endblock %}
- create matching javascript file with syntax highlighting, e.g., https://github.com/assembliss/webassembliss/blob/main/webassembliss/static/js/x8664_linux.js
- if needed, add any extra setup you might need for the base functions, e.g.,
webassembliss/webassembliss/static/js/x8664_linux.js
Lines 14 to 19 in ecf9695
// Initialize all flags as false. document.getElementById("sfFlag").innerHTML = ERROR_SYMBOL; document.getElementById("zfFlag").innerHTML = ERROR_SYMBOL; document.getElementById("cfFlag").innerHTML = ERROR_SYMBOL; document.getElementById("ofFlag").innerHTML = ERROR_SYMBOL; BASE_startTracing(combineAllSteps);
-
add new editor to dropdown menu, e.g.,
webassembliss/webassembliss/templates/base.html.j2
Lines 31 to 32 in ecf9695
<li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="/editor/x8664_linux">x86-64 (linux)</a></li> -
add new editor to landing page, e.g.,
webassembliss/webassembliss/templates/index.html.j2
Lines 21 to 22 in ecf9695
<li><hr class="dropdown-divider"></li> <li><a class="text-center dropdown-item" href="/editor/x8664_linux">x86-64</a></li> -
create a new emulation file to use appropriate commands and flags for the architecture, e.g., https://github.com/assembliss/webassembliss/blob/main/webassembliss/emulation/x8664_linux.py
-
add at least a
hello worldexample for the architecture, e.g., https://github.com/assembliss/webassembliss/tree/main/webassembliss/examples/x8664_linux -
add new entry in the
ARCH_CONFIG_MAP, e.g.,webassembliss/webassembliss/emulation/arch_config.py
Lines 38 to 44 in ecf9695
"x8664_linux": ArchConfig( trace=x8664_linux_trace, template_path="x8664_linux.html.j2", example_path=join(EXAMPLES_PATH, "x8664_linux", "hello.s"), example_name="hello.s", inline_comment_tokens=["#"], ), -
add new enum value in the
project_config.proto, e.g.,x8664_linux = 3;
- Important: this value should match the key you added to
ARCH_CONFIG_MAP
- recompile
project_config.protoso the python backend can see the new enum value:// This file can be compiled with: protoc project_config.proto --python_out=../../pyprotos // That will generate the project_config_pb2.py file that we can import in the python backend.
All done! Make sure to test things out and double check everything works fine.
Eventually, we'll have unit testing for all modules (once file structure and naming are stable); at that time, I'll add follow-up comments to this issue with instructions of how to add tests for your new architecture.