[Object] Add binary format for bundling offloading metadata
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 25 Mar 2022 15:02:29 +0000 (11:02 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 14 Apr 2022 14:50:52 +0000 (10:50 -0400)
commite471ba3d0122d4c6601029d81c385cb6ebb9d7a4
tree4c59499ec02741bf3667a3935cf5cbf8d04fe262
parent11f47b791f96ca04b4cf9233d72febc704606dcf
[Object] Add binary format for bundling offloading metadata

We need to embed certain metadata along with a binary image when we wish
to perform a device-linking job on it. Currently this metadata was
embedded in the section name of the data itself. This worked, but made
adding new metadata very difficult and didn't work if the user did any
sort of section linking.

This patch introduces a custom binary format for bundling offloading
metadata with a device object file. This binary format is fundamentally
a simple string map table with some additional data and an embedded
image. I decided to use a custom format rather than using an existing
format (ELF, JSON, etc) because of the specialty use-case of this. We
need a simple binary format that can be concatenated without requiring
other external dependencies.

This extension will make it easier to extend the linker wrapper's
capabilties with whatever data is necessary. Eventually this will allow
us to remove all the external arguments passed to the linker wrapper and
embed it directly in the host's linker so device linking behaves exactly
like host linking.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D122069
llvm/include/llvm/Object/OffloadBinary.h [new file with mode: 0644]
llvm/lib/Object/CMakeLists.txt
llvm/lib/Object/OffloadBinary.cpp [new file with mode: 0644]
llvm/unittests/Object/CMakeLists.txt
llvm/unittests/Object/OffloadingTest.cpp [new file with mode: 0644]