I'm working on an assembler for the 8086 . My question is how do you convert the hex opcodes to an executable file like .EXE,.ELF,.COM,a.out etc .Looking for links/resources for this and should the assembler do the linking process or is it done by the OS automatically?
It's fairly complicated, and usually involves two steps:
Thus the assembler will generally not output executable files; you need to pick an object file format and read up on how to generate that. In theory, as long as you output a valid object file in a given format, any linker should be able to do the actual linking process, but usually assemblers and linkers come as a set, so I'm not sure how well it will actually work in practice (for example, the GNU assembler (gas) outputs GNU-specific relocations and sections that the GNU linker (ld) knows how to handle, so you can't use gas-generated object files in any other linker)
ELF is documented in section 4 of the SV ABI , although you'll need to read your processor's addendum too. COFF is documented as part of the PE spec, although I can't find it hosted on the Internet anywhere; if you need it I can post it somewhere
它取决于(目标)平台,但对于Windows PE格式(EXE),您的工作是生成obj文件 ,让Linker完成剩下的工作。
Here's an article that discusses some executable formats. It should get you started, assuming you're on Windows.
http://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.