16-Bit Data Pointers on RV32

3 pointsposted 11 hours ago
by todsacerdoti

2 Comments

fwsgonzo

10 hours ago

That's cool! I do have a habit of writing ELF post-processors as a part of the CMake build system I inevitably end up writing. There's a handy POST_BUILD you can attach to programs which I use very often for things like execute-only (XO) and apparently also to rewrite function entries for functions I can't --wrap.

Example: https://github.com/varnish/libvmod-riscv/blob/main/program/c...

chperm can change the permissions of a segment to just execute, instead of read+execute. Of course, you will need a custom linker script because the default linker scripts will merge .text and read-only data to save space.

Currently, I'm battling a Rust program that has a built-in function called __memcmpeq, which isn't a global, so I can't --wrap it.

wren6991

7 hours ago

ELF patching is a last resort! We do have some really awful Python ELF patching in the RP2350 ROM build to implement a missing relocation for 16-bit pointers in `movw` instructions, which also saves a ton of space.