Bitwise » Forums » Making valid .bin files in x64 compiler
huzaifa
1 posts
#17253 Making valid .bin files in x64 compiler
3 weeks, 6 days ago Edited by huzaifa on Jan. 26, 2019, 2:45 p.m.

In the three part series of the "Programming a x64 compiler from scratch", the first part confused me a bit. Per wrote bytes to a .bin file, and when he disassembled it, it was working. Seemingly, he wrote machine code without an assembler or a compiler. When I tried the same thing, the objdump program threw an error, stating that the .bin file is corrupt or invalid. How could I resolve this?
mmozeiko
Mārtiņš Možeiko
1882 posts / 1 project
#17256 Making valid .bin files in x64 compiler
3 weeks, 6 days ago

Did you try writing exact same bytes as he did, or this is your custom thing you wrote?
To diagnose why something is not working here you should open file in hexeditor and go byte by byte over it, starting from top. Look up structure descriptions that specifies how executable format is defined, and verify that your bytes are exactly what should be.