racerxdl / riscv-online-asm

RISC-V Online Assembler using Emscripten, Gnu Binutils
https://riscvasm.lucasteske.dev
39 stars 9 forks source link

Loads wrong addresses #3

Closed Jar0T closed 1 year ago

Jar0T commented 1 year ago

Using: la t0,

racerxdl commented 1 year ago

Do you have a full example?

Technically the code is located fixed at address 0x0, thats why it changes to 0.

Jar0T commented 1 year ago
.global _boot
.text

_boot:
    addi x1, x0, 100
    la x2, temp

.data
temp:
    .byte 10

This code results in loading address of la x2, temp instead of temp

racerxdl commented 1 year ago

Just found the issue. I need to specify a linker script, otherwise it defaults to linux one, which expects linux-ld to fill the section offsets. I'm updating the tool with the fixes :D

racerxdl commented 1 year ago

Now it generates correctly: image

And you can change the real offsets in the linker script :D