Is There Any Way To Generate ELF BINARY Using Only Python Library?
Is there any way to generate
ELF binary using only the python library?
I want to assemble the file below using python library.
line 1 : .global _start line 2 : _start: line 3 : push _STRING1 line 4 : push _STRING2 line 5 : call printf line 6 : _STRING1: line 7 : .string "gogo" line 8 : _STRING2: line 9 : .string "%s"
I've tried to use two python libraries
However, they support only machine code byte emission corresponding to assembly command.
(It didn't generate
ELF binary consisting of elf header, section header,.. etc)
Also, It doesn't support handling on external library info. (such as
Q. I wanna generate a complete ELF BINARY
a.out using python library.
Is there any possible way to do that?
I want to assemble the below file
Note that your program is ill-defined:
printf, but you didn't allow C runtime to be initialized. (If you want to call any libc functions, you should let the
_startto be defined in
crt0.o, and your program should start at
You don't properly terminate your program (don't call
_exit, or execute
SYS_exitsyscall). You can return from
_startwill then execute
SYS_exitfor you), but you must not return from
_start, and certainly not fall from the end of it to whatever code or data is immediately after it.
Back to your original question: it's possible to "hand-assemble" an ELF file -- data is data.
However, that's a lot of work (and pretty pointless work), so you are much better off simply invoking external assembler and linker.
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module