Dwarf hello world assembly example or tutoral?

谁说胖子不能爱 提交于 2019-12-06 07:06:31

问题


I'm writing an assembly level human speakable programming language in nasm. I've noticed that Dwarf debugging is an essential component to developing it.

In order for it to become self-hosting later on, will not only have to compile to ELF, but also support Dwarf to make debugging viable. For ELF there is a wonderful nasm example of how to make an ELF header http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html http://blog.markloiseau.com/2012/05/tiny-64-bit-elf-executables/

I'm wondering if there is or even could be made something similar for DWARF, an example hello world, that includes the DWARF sections required for it to work with gdb. With such an example it would be much easier to understand DWARF, rather than going through rather cryptic documentation, that mostly refers to C. The closest I've found is a guide by IBM that has a little program that lets you selectively dwarf dump on a per function basis www.ibm.com/developerworks/library/os-debugging/

Anyways if you happen to be able to make a nasm hello world dwarf example, I'm sure the world will much appreciate it, since it will make the dwarf format more accessible. Maybe someone will then even be able to implement it in fasm or other assemblers than nasm.


回答1:


If you don't mind digging a bit, there is a simple "DWARF assembler" in the gdb test suite. See src/gdb/testsuite/lib/dwarf.exp. It's pretty easy to understand and despite its name it writes out assembly code. You can grep through the rest of the test suite to see examples of how it is used.



来源:https://stackoverflow.com/questions/20930801/dwarf-hello-world-assembly-example-or-tutoral

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!