Created
August 24, 2017 11:52
-
-
Save janhieber/aed6f62e0b175aaefb2d3b11d531db3c to your computer and use it in GitHub Desktop.
Link blob into C program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assume, gzipped static html with embedded CSS and JS named html.gz | |
# note: browser can unzip it when header is correct! save space! | |
# make binary object from data | |
arm-none-eabi-ld -r -b binary -o html.o html.gz | |
# put in read only section | |
arm-none-eabi-objcopy.exe --rename-section .data=.rodata,alloc,load,readonly,data,contents html.o html.o | |
# print symbols, just FYI | |
arm-none-eabi-objdump.exe -t html.o | |
# C code | |
/** start symbol of blob */ | |
extern const unsigned char _binary_html_gz_start; | |
/** end symbol of blob */ | |
extern const unsigned char _binary_html_gz_end; | |
/** pointer to access blob */ | |
static const uint8_t* blob = (uint8_t*) &_binary_html_gz_start; | |
/** size of blob */ | |
#define blob_len ((size_t)((uint32_t)&_binary_html_gz_end) \ | |
- ((uint32_t)&_binary_html_gz_start)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment