I am new to RISC-V. I want to convert that MATLAB code(M-file) to RISC-V Assembly code, can anyone give some suggestions or inputs on how can I do it.
Regards,
Yulia
Disclaimer: i know rather few things about m-files and stuff 😉
Perhaps using https://github.com/csafonov/tinymc to generate c code and using gcc to compile into a risc-v binary might work.
Hope that helps nevertheless.
Regards
Joachim
Related
I am quite new to assembly and Linux as a whole. I found on gitHub a space invader program written in Assembly. But I tried compiling and running it, but have no clue how.
I first thought I could use gcc -o name name.s and that didnt work.
Like I said I am completely new to usuing linux and I would greatly appreciate it if someone could explain to me how to compile this and get it running.
Here's the link : https://github.com/timotei/Space-Invaders-Clone/blob/master/spacein.asm
Under linux the standard assembler is as. If you want to use assembler sources inside a c or c++ environment you can give the compiler e.g. gcc a hint with -xassembler or xassembler-with-cpp if you want to use the C-preprocessor. Normally gcc also accepts assembler sources if the name of the file ends with standard file name like *.s or *.S.
There is already another question here which handles dos assembler:
Taking an Assembly Course, Stuck in DOS!
And maybe you find some other discussions helpful:
https://www.winehq.org/pipermail/wine-users/2007-November/028174.html
But I have no idea why someone wants to start with assembler on x86 at all if you are not a os programmer or kernel hacker. :-)
I've been learning how to write exploits using stack-based buffer overflows and, the one thing I cannot comprehend is just how the code (I believe "Machine Code") is interpreted and used. What I am talking about is the "/x3b/x09..." used in the actual injection of arbitrary code. I would like some clarification on how a simple "Hello World" program can be turned into what looks like hexadecimal, and that if the usage of this as a payload would be platform-specific. Any clarification would be greatly appreciated, thanks.
It's interpreted by the CPU. That is the binary machine code that the CPU actually processes, just like the code that's created when you compile a program in C or C++.
Yes, it's platform-specific, just like compilers have to generate code for a specific platform.
I'd like to understand & edit(adding printk, etc.) the linux kernel for a craneboard, which I obtained from github. I'm a newbie. I have gone through certain questions related to this in stackoverflow, but they all concentrate on linux in PC (not in embedded!). I don't know where to start. Any kind of guidance is accepted. Thanks in advance.
Dear did you got chance to look at README located at
https://github.com/craneboard/craneboard-kernel
if you need to add any information or some logging i.e. adding printk in kernel itslef, you need to recompile it, it also shows how to do it. But i am interested to know why you need to put logging information in kernel? Are you going to fix some bug in kernel?
Printk is same like a C Printf, but with few differences http://www.makelinux.net/books/lkd2/ch18lev1sec3
Also have a look at http://processors.wiki.ti.com/index.php/CraneBoard
It might also be a good start to look at https://linuxlink.timesys.com/files/pdf/Timesys-EmbeddedLinuxTutorial.pdf
You'll need an ARM toolchain before you can compile the kernel. Here is a good tutorial.
Is there any way to decompile Linux .so?
There are decompilers, but a decompiler might not emit code in the same language that the original program was written in.
There are also disassemblers, which will reassemble the machine code into assembly.
The Decompilation Wiki may be a good source of additional information.
You can disassemble the code with objdump(1) for example.
I need to do a rather unusual thing: manually execute an elf executable. I.e. load all sections into right places, query main() and call it (and cleanup then). Executable will be statically linked, so there will be no need to link libraries. I also control base address, so no worries about possible conflicts.
So, is there are any libraries for that?
I found OSKit and its liboskit_exec, but project seems to be dead since 2002.
I'm OK with taking parts of projects (respecting licenses, of course) and tailoring them to my need, but as I'm quite a noob in the linux world, I dont even know where to find those parts! :)
PS. I need that for ARM platform.
UPD Well, the matter of loading elfs seems to require some good knowledge about it (sigh), so I'm out to read some specs and manuals. And I think I will stick to bionic/linker and libelfsh. Thanks guys!
Summarized findings:
libelf: http://directory.fsf.org/project/libelf/
elfsh and libelfsh (are now part of eresi): http://www.eresi-project.org/
elfio (another elf library): http://sourceforge.net/projects/elfio/
OSKit and liboskit_exec (outdated): http://www.cs.utah.edu/flux/oskit/
bionic/linker: https://android.googlesource.com/platform/bionic
A quick apt-cache search suggests libelf1, libelfg0 and/or libelfsh0. I think the elfsh program (in the namesake package) might be an interesting practical example of how to use libelfsh0.
I haven't tried any myself, but I hope they might be helpful. Good luck :-)
Google's Android, in it's "bionic" libc implementation, has a completely reimplemented ELF loader. It's reasonably clean, and probably a better source than gilbc if you're looking for something simple.
Take a look at libelf for reading the executable format. You are going to have trouble with this I think.
Sounds like, as you don't need libraries for anything, why not just mmap your executable, set data about various memory areas and jmp/b in?
I don't know if ARM has an NX-bit equivalent, but worth checking.
This tool contains an ELF loader: http://bitwagon.com/rtldi/rtldi.html
I reused the code from rtldi for an ELF chainloader in another project. The code is here: http://svn.gna.org/viewcvs/plash/trunk/chroot-jail/elf-chainloader/?rev=877 and there is some background here: http://plash.beasts.org/wiki/Story16. (Apparently I have to break these links because stackoverflow won't let me post >1 link!)