Simple BOF Runner

This project demonstrates running a Beacon Object File with a PIC loader.

Project Files

Notes

To generate a PIC loader to a run a BOF, use:

./link loader.spec /path/to/bof.x64.o out.bin

This example is most interesting as a demonstration of another way to prepare and run BOFs within a PIC capability.

The bofprep.spec script merges a partial implementation of the Beacon Object File API into a BOF and uses attach to resolve the BOF API imports to the merged functions. This approach greatly reduces the code needed in a capability context to run a BOF. This script is a re-usable base for other projects.

The loader.spec script accepts a BOF as an argument, turns it into a PICO, and uses bofprep.spec to bring in the API. The +optimize flag ensures unused API functions are removed from the BOF at export. The BOF PICO is appended to the loader and linked to the my_data section.

The loader.c file is our BOF runner. You'll notice it's no different from a PICO runner, because PICOs are BOFs without the API. This program implements one function from the Beacon API and that is BeaconOutput. This function is made available to the PICO via the BOFIMPORTS struct (loader.c) and the import command in bofprep.spec. The .spec file import command tells the PICO loader which functions to expect in the struct passed to PicoLoad.

This loader doesn't pass arguments to the BOF.

Conversation

License

This project is licensed under the BSD License.