syntacore / snippy

Other
43 stars 4 forks source link

Add Option to Generate Non-Relocatable ELF File #50

Closed m4drat closed 3 months ago

m4drat commented 3 months ago

Hi!

While using Snippy, I've found that for my use-case, I need only the raw machine code. To achieve this, I need an option to build the resulting ELF without relocations, from which I can extract the code and run it in my environment.

As a temporary solution, I've just changed the relocatable parameter value in the following call: https://github.com/syntacore/snippy/blob/35b9673a4c2ca61f301ff45a4fd85d16baf38c81/llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp#L124

Would it be possible to add an option in Snippy to generate a non-relocatable ELF file directly?

Thank you!

m4drat commented 3 months ago

Oh, my bad, found a way to do it directly using the linker: riscv64-linux-gnu-ld ./snippet.elf -o ./snippet-final.elf -T ./snippet.elf.ld.

Closing the issue, as it is basically the solution.