[File] [PATCH] Add support for AMD/Xilinx accelerator xclbin binary files

Sonal Santan sonal.santan at amd.com
Thu Dec 1 22:55:55 UTC 2022


Hello,

This patch adds support to recognize "xclbin" binary files used by
AMD/Xilinx accelerators like Alveo--

https://www.xilinx.com/products/boards-and-kits/alveo.html

The xclbin files are defined as part of XRT source tree--

https://github.com/Xilinx/XRT/blob/master/src/runtime_src/core/include/xclbin.h

The patch updates magic/Magdir/xilinx to recognize xclbin files. A test
has been added to the tests directory which includes a 512B snippet of
a xclbin binary file.

I hope this can be applied to a future version of the file utility.

-Sonal

Signed-off-by: Sonal Santan <sonal.santan at amd.com>
---
 magic/Magdir/xilinx   |  18 ++++++++++++++++++
 tests/Makefile.am     |   2 ++
 tests/xclbin.result   |   1 +
 tests/xclbin.testfile | Bin 0 -> 512 bytes
 4 files changed, 21 insertions(+)
 create mode 100644 tests/xclbin.result
 create mode 100644 tests/xclbin.testfile

diff --git a/magic/Magdir/xilinx b/magic/Magdir/xilinx
index b5443cbf..32d754d2 100644
--- a/magic/Magdir/xilinx
+++ b/magic/Magdir/xilinx
@@ -38,3 +38,21 @@
 # Raw bitstream files
 0      long    0xffffffff
 >&0    belong  0xaa995566      Xilinx RAW bitstream (.BIN)
+
+# AXLF (xclbin) files used by AMD/Xilinx accelerators.
+# The file format is defined by XRT source tree:
+#
https://github.com/Xilinx/XRT/blob/master/src/runtime_src/core/include/xclbin.h
+# Display file size, creation date, accelerator shell name, xclbin uuid and
+# number of sections.
+
+0   string      xclbin2     AMD/Xilinx accelerator AXLF (xclbin) file
+>0x130	lequad 		x   	\b, %lld bytes
+>0x138	leqdate 	x   	\b, created %s
+>0x160	string		>0	\b, shell "%.64s"
+>0x1a0	ubelong		x	\b, uuid %08x
+>0x1a4	ubeshort	x	\b-%04x
+>0x1a6	ubeshort	x	\b-%04x
+>0x1a8	ubeshort	x	\b-%04x
+>0x1aa	ubelong		x	\b-%08x
+>0x1ae	ubeshort	x	\b%04x
+>0x1c0  lelong          x       \b, %d sections.
\ No newline at end of file
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1dd6dc89..03dc645e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -101,6 +101,8 @@ regex-eol.result \
 regex-eol.testfile \
 uf2.result \
 uf2.testfile \
+xclbin.result \
+xclbin.testfile \
 zstd-3-skippable-frames.result \
 zstd-dictionary-0.result \
 zstd-dictionary-1.result \
diff --git a/tests/xclbin.result b/tests/xclbin.result
new file mode 100644
index 00000000..867a3f58
--- /dev/null
+++ b/tests/xclbin.result
@@ -0,0 +1 @@
+AMD/Xilinx accelerator AXLF (xclbin) file, 46226070 bytes, created Fri
Mar 25 00:51:37 2022, shell "xilinx_u55c_gen3x16_xdma_3_202210_1", uuid
e106e953-cf90-4024-e075-282d1a7d820b, 11 sections.
diff --git a/tests/xclbin.testfile b/tests/xclbin.testfile
new file mode 100644
index
0000000000000000000000000000000000000000..7a965c15075dbdac1d06bb2c3be28c2b639a2120
GIT binary patch
literal 512
zcmb<O&PmG5Gh+BZ3h;)2q>ybA0}xD$I>-c~VSEr91a>nr at iIb~C}c%uPG(+3e5t8v
za(sGfo^getS$suGZeqM~ype&Ck)c7nA&Po*&O^4B!RIG9s5~gu(3Prf;zpN87AQz8
ZD#=XDK~d7c4B at s-KLB<&8;UFg0{~!AJz at X=

literal 0
HcmV?d00001

-- 
2.34.1




More information about the File mailing list