http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p104...
Embedding Binary Objects in C
21–30 of 141 posts
Re: Embedding Binary Objects in C
#22The author puts a lot of work towards making this proposal a reality (as far as I as a casual twitter/slack observer can see) and I'm looking forward to it.
Re: Embedding Binary Objects in C
#23Or, as any CTFer worth their salt will tell you, __asm__(“.incbin file”);
CTF = ?
Re: Embedding Binary Objects in C
#24My favorite is simply using a tool to create a C file with your binary data: static uint8_t mydata[] = {0xDE, 0xAD, 0xBE, 0xEF, ... }; The advantage is that it works anywhere, with any compiler. The disadvantage is that it can increase compile time. I would limit each .c file to 10MB; it seems there's a quadratic increase in build time with file size, at least with gcc. Also, instead of "0x%02x" I use decimal notatio…
xxd -i filename.binRe: Embedding Binary Objects in C
#25If we're in the realm of "non-standard linker tricks"... Compilers will concatenate sections of the same name. You can use this trick to produce a concatenation of arrays across several files: $ cat t1.c __attribute__((section("some_array"))) int a[] = {1, 2, 3}; $ cat t2.c __attribute__((section("some_array"))) int b[] = {4, 5, 6}; $ cat t.c #include extern const int __start_some_array; extern const int __stop_some_…
Re: Embedding Binary Objects in C
#26It works pretty well, though I don't believe it works on Windows.
Re: Embedding Binary Objects in C
#27My favorite is simply using a tool to create a C file with your binary data: static uint8_t mydata[] = {0xDE, 0xAD, 0xBE, 0xEF, ... }; The advantage is that it works anywhere, with any compiler. The disadvantage is that it can increase compile time. I would limit each .c file to 10MB; it seems there's a quadratic increase in build time with file size, at least with gcc. Also, instead of "0x%02x" I use decimal notatio…
Re: Embedding Binary Objects in C
#28Re: Embedding Binary Objects in C
#29My favorite is simply using a tool to create a C file with your binary data: static uint8_t mydata[] = {0xDE, 0xAD, 0xBE, 0xEF, ... }; The advantage is that it works anywhere, with any compiler. The disadvantage is that it can increase compile time. I would limit each .c file to 10MB; it seems there's a quadratic increase in build time with file size, at least with gcc. Also, instead of "0x%02x" I use decimal notatio…
if you do that you could also do base64 ;)
Re: Embedding Binary Objects in C
#30Generating assembly files is my favorite way of including outside data into my C programs.