News for hackers. Stuff that matters.
Re:Exploring Object File Formats by eterps on Tuesday January 16, 2024 @06:41AM (#39012181)
I have a soft spot for the brutal simplicity of the .COM format.
Re:Exploring Object File Formats by 082349872349872 on Tuesday January 16, 2024 @08:50AM (#39013241)
Both ELF and Mach-O (and presumably other recent formats) are amenable to a pseudo-COM approach: https://news.ycombinator.com/item?id=38593896
Re:Exploring Object File Formats by actionfromafar on Tuesday January 16, 2024 @09:58AM (#39013926)
Also see the pure brutality that is the early Microsoft Office DOC file. :) Just dumping the memory IIRC.
Re:Exploring Object File Formats by fullspectrumdev on Tuesday January 16, 2024 @11:13AM (#39015014)
I vaguely recall reading that on some versions of Office way back when, memory from other programs would sometimes leak into saved document files.

(Pauses commenting to go check) yes it’s referenced in Chapter 3 of “Silence on the Wire”, apparently Office on Windows 95/98 would dump memory from “other programs” into word docs, with some anecdotal sightings in later versions.

Re:Exploring Object File Formats by actionfromafar on Tuesday January 16, 2024 @11:41AM (#39015325)
Maybe a case of reused allocated memory and just writing chunks of memory to disk. Simplistic example:

struct blah_block{ int sz; char buf[510]; }

Re:Exploring Object File Formats by WalterBright on Tuesday January 16, 2024 @01:58PM (#39017299)
What's interesting about that is every tool I've seen to generate .com files would set SS=DS=ES=CS to the same value.

But, it turns out, this is not necessary. The only thing about COM is that the file size has to be less than 64K. This enables another memory model, where the code seg and data seg are different, enabling substantially larger programs that were still COM programs. This was the Zortech "small" memory model.

Re:Exploring Object File Formats by pjmlp on Tuesday January 16, 2024 @07:55AM (#39012763)
Nice to see an article that remembers AIX isn't about ELF.

Symbian also used a COFF variant.

Re:Exploring Object File Formats by boricj on Tuesday January 16, 2024 @08:04AM (#39012831)
I've written an ELF object file exporter as part of a Ghidra extension [1]. It's a bit finicky to get it right (toolchains assume that object files are valid and don't have much in the way of diagnostics), but these are fairly simple under the hood. Section bytes, symbols and relocations, with some headers and metadata to wrap these up...

It's a bit of a shame that object files aren't more of a lingua franca of toolchains in practice. Embedding binary blobs inside a program in a portable way is still a mess today.

[1] https://github.com/boricj/ghidra-delinker-extension/tree/mas...

Re:Exploring Object File Formats by khaledh on Tuesday January 16, 2024 @09:14AM (#39013444)
Low-level programming is one of my favourite subjects. I've written a simple ELF parser in Nim (with the help of an amazing binary parsing library) among other things: https://github.com/khaledh/elfdump
Re:Exploring Object File Formats by a2code on Tuesday January 16, 2024 @11:54AM (#39015515)
How did you learn to do this?
Re:Exploring Object File Formats by hnthrowaway0328 on Tuesday January 16, 2024 @05:00PM (#39019746)
Just read the ELF specification. There is a header and everything else follows. There are a lot of explanations online, here is one: https://www.cs.cmu.edu/afs/cs/academic/class/15213-f00/docs/...
Re:Exploring Object File Formats by khaledh on Tuesday January 16, 2024 @07:09PM (#39021117)
My reference was the "System V Application Binary Interface" itself (chapter 4). It's not that difficult to grok.

https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf

Re:Exploring Object File Formats by eddd-ddde on Tuesday January 16, 2024 @09:45AM (#39013790)
That reminds me, couple of years ago when I was leaning to program, one of my first projects was a ELF parser so I could understand what binaries where doing and how they where built.
Re:Exploring Object File Formats by WalterBright on Tuesday January 16, 2024 @01:55PM (#39017234)
In order to learn an object file format, the first thing I'd do is write a dumper for it.
Re:Exploring Object File Formats by mhh__ on Tuesday January 16, 2024 @07:38PM (#39021451)
Writing a program that can dump itself is a great learning project.

Good bit twiddling practice too

Re:Exploring Object File Formats by xvilka on Tuesday January 16, 2024 @09:43AM (#39013753)
Always quality content in that blog. We used MaskRay's article[1] on stack unwinding to improve our debuginfo (DWARF) support[2] in the past. If someone wants to have a more hands-on approach to executable file formats, e.g., XCOFF or GOFF, they can check Rizin's ideas for new formats[3] to support.

[1] https://maskray.me/blog/2020-11-08-stack-unwinding

[2] https://rizin.re/posts/gsoc-2023-dwarf/

[3] https://github.com/rizinorg/ideas/issues?q=is%3Aissue+is%3Ao...

Re:Exploring Object File Formats by norir on Tuesday January 16, 2024 @12:15PM (#39015824)
Nice overview. They didn't get to the hideous self-referential (and largely undocumented) trie that is used for the symbol name mappings in mach-o. Not fun to implement. And frustrating because there is so much wasted space in typical mach-o binaries that it seems very much not worth the compression effort, at least by I don't know 2005?
Re:Exploring Object File Formats by theresistor on Wednesday January 17, 2024 @08:20PM (#39036237)
In the early days of Swift, binary size bloat due to huge symbol tables was a serious problem. We had some real binaries where the symbol table was more than half of the entire file.
Re:Exploring Object File Formats by snvzz on Tuesday January 16, 2024 @12:25PM (#39015949)
Notably missing is HUNK, AmigaOS's object file format.