rbelftools icon indicating copy to clipboard operation
rbelftools copied to clipboard

Add EM_RISCV constant

Open nomadium opened this issue 2 years ago • 6 comments

Hi folks,

I was working with some RISC-V ELF binaries and I thought it would be convenient to have them properly recognised by this library so I'm submitting a small change to improve RISC-V architecture support.

Thanks.


References:

  • https://www.sco.com/developers/gabi/latest/ch4.eheader.html

  • https://github.com/bminor/glibc/commit/94e73c95d9b5ac7d3b3f178e2ca03ef6b60e82aa

  • https://www.google.com/search?q=EM_RISCV

nomadium avatar Feb 15 '23 20:02 nomadium

Thanks for the PR! Only one feedback that I want the coverage be kept as 100%, please enhance the tests to cover the new line.

david942j avatar Feb 22 '23 16:02 david942j

Thanks for the feedback. Sure, no problem, I'll update the PR soon.

nomadium avatar Feb 22 '23 16:02 nomadium

@david942j it took me ages to add unit tests to this PR but hey, such is life.

My only concern at the moment it's that I added a binary (it's just a hello world) riscv64 file to the repo without a clear way how to build it.

I could update the Makefile to add a cross-compiler in similar way to what is done here:

https://github.com/popovicu/risc-v-bare-metal-fake-bios/blob/main/Makefile

But then this small library would be depending on the whole riscv64 toolchain and I don't think that's the right path.

nomadium avatar Oct 15 '23 13:10 nomadium

How about adding a Dockerfile that could include all needed toolchain?

david942j avatar Oct 16 '23 15:10 david942j

I like that idea, do you have an example of another ruby gem shipping a Dockerfile?

nomadium avatar Oct 16 '23 20:10 nomadium

You don't need a Ruby gem, just provide a Dockerfile under spec/files along with a README to describe the sequence of commands to generate the riscv binary (i.e. docker build; docker run... docker exec gcc ...). The Dockerfile can be based on the latest Ubuntu image and install required cross compiler.

As long as I can follow the README you provided to generate the same binary it's good enough :)

david942j avatar Oct 17 '23 13:10 david942j