What relocation entries are copied from pdex.elf to pdex.bin?


Hi all,

I'm trying to understand the new pdex.bin file format, although most of the things looks straightforward, it's a bit confusing that what relocation entries are actually copied from the pdex.elf to the pdex.bin. I'm not sure if discussion of this is appropriate for the forum or if playdate devs are willing to make some response... I'm just curious how it works.

You asked this question elsewhere where I answered it, but for posterity I'll fill in some details in this thread as well:

pdex.elf is the intermediate binary produced by the C compiler, which is then passed to pdc to produce pdex.bin.

pdex.elf should be compiled with the -mword-relocations flag, which (according to the GCC docs) instructs the compiler to "only generate absolute relocations on word-sized values" of type R_ARM_ABS32. If you're compiling using the Make/CMake files shipped with the Playdate SDK, this is already handled for you. (Side note: if your compiler doesn't support -mword-relocations (e.g. the Zig compiler), you can try passing -fPIC which usually implies -mword-relocations.)

pdex.bin is just pdex.elf file stripped down to its essentials. When you run pdc to produce pdex.bin from pdex.elf, it more or less just copies the contents of the ELF program segment and all R_ARM_ABS32 relocation entries and outputs it all in a zlib-compressed format.

1 Like