How include to build object file the last bytes of binary file The as contain directive incbin, but i don know how select range relative to the end of file
I know how to extract a range of bytes into a new file and use it in a Makefile. This works, but the sizes of these files are in terabytes
This looks to be one of the cases where the programmer not only needs to know their programming language, but also their build system.
So you let the build system write the
.incbindirective with the proper numbers.If the binary file is called
bar.binand I want that as a global symbolbar, I would do something along these lines (presuming a make based build system):So if
bar.binis 256 bytes, this will generate a filewhich will then be included into
foo.Swhenfoo.Sis being assembled.There are other ways do to this as well. E.g.
So if
bar.binis 1TiB = 1099511627776 in size, this will generate abar.Sto be assembled which looks likewhich will then be assembled into an object file
bar.owhich contains the 16 byte aligned symbolbarof size16which contains the last 16 bytes of thebar.binfile.