hex2(1)
π hex2 β the trivially bootstrappable linker π
okay so bestie, this is hex2(1), from the User Manuals, and it is literally the trivially bootstrappable linker that is designed to be introspectable by humans. no cap. π¦
β¨ SYNOPSIS β¨
hex2 --architecture ARCHITECTURE --base-address ADDRESS --file FILE
[--output FILE [--non-executable]]
πΈ DESCRIPTION πΈ
hex2 exists so that actual humans β not compilers, not build systems, not some mysterious wizard in the cloud β can write elf files and other binary files by hand, in a format that lets you drop comments in and actually understand what you're looking at. it's giving β¨artisanal binariesβ¨.
At the very core of it? read 2 hex characters, add them together, output a single byte. that's the whole vibe. π
You can override that and use binary or octal input instead if you want to, using the --octal or --binary option. your input, your rules, periodt.
If no output file is specified, the output gets sent to standard out. and by default the file will be executable β unless you also pass --non-executable. choose your own adventure. π
π§ the ARCHITECTURES (the supported ones, anyway)
knight-nativeknight-posixx86amd64armv7laarch64
If you fail to specify an architecture, the default of knight-native gets used. π«Ά
The base address β like, the address the binary is meant to be loaded into memory at, and therefore the thing your relative and absolute pointers are based on β is passed via --base-address. if you don't provide it, the default value of ZERO is assumed. zero. zilch. nada. iconic honestly.
π·οΈ labels, bestie
hex2 also supports labels in the :LABEL format, plus relative and absolute pointers to those labels in 8, 16, 24 or 32 bit sizes. so:
!LABELβ 8 bit relative address@LABELβ 16 bit relative address~LABELβ 24 bit relative address%LABELβ 32 bit relative address$LABELβ 16 bit absolute address&LABELβ 32 bit absolute address
Should you wish to specify the bit and byte encoding of the addresses to match your target, you've got --big-endian and --little-endian. slay. π
π§ the < and ^ situation (word alignment girlies)
On architectures that require word alignment, the < and ^ characters have a special meaning. specifically:
- pad to word
- use word base address calculation rather than standard byte based address calculation
generally seen in the form: ^~LABEL EB for calls in ARM. iykyk. π
π EXAMPLES π
Typically, hex2 will be called in scripts used in bootstrapping:
# hex2 -f ELF-armv7l.hex2 -f cc.hex2 --little-endian --architecture armv7l --base-address 0x10000 -o cc
π₯ COMPATIBILITY π₯
hex2 is compatible with all Turing complete machines β even the ones that try to be Turing complete -1. ππ
π AUTHORS π
- Jeremiah Orians
<Jeremiah@pdp10.guru> - Jan (janneke) Nieuwenhuizen
<janneke@gnu.org>
πΈ COPYRIGHT πΈ
Copyright 2016-2019 Jeremiah Orians <Jeremiah@pdp10.guru>
Copyright 2017 Jan Nieuwenhuizen <janneke@gnu.org>
License GPLv3+.
β SEE ALSO β
and that's the whole page, bestie π©· this one came out of the Linux manual set, dated JULY 2019, and it's hex2(1) through and through. go hand-write a binary, you absolute main character. πβ¨π
π¦ where this page comes from
- debian bookworm: mescc-tools 1.4.0-1 Β· GPL-3.0-or-later
- debian trixie: mescc-tools 1.5.2-1 Β· GPL-3.0-or-later
- ubuntu jammy: mescc-tools 1.3-2 Β· GPL-3.0-or-later
- ubuntu noble: mescc-tools 1.4.0-1 Β· GPL-3.0-or-later
- ubuntu questing: mescc-tools 1.5.2-1ubuntu1
- ubuntu resolute: mescc-tools 1.5.2-1ubuntu2 Β· GPL-3.0-or-later
- ubuntu stonking: mescc-tools 1.5.2-1ubuntu2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms