I have the following macro to embed a file in my code and it works just fine:
.macro add_resource resource_name, file_name
.global resource_name
.type resource_name, @object
.balign 4
resource_name:
.incbin "file_name"
end_resource_name:
.global size_resource_name
.type size_resource_name, @object
.balign 4
size_resource_name:
.int end_resource_name - resource_name
.endm
.section .rodata
add_resource icon, "icon.png"
and the usage:
#include <stdio.h>
extern unsigned char icon[];
extern unsigned int size_icon;
int main() {
printf("magic bytes: %.3s, size: %u", icon+1, size_icon);
return 0;
}
which prints “magic bytes: PNG, size: 16350077”. But the name “size_icon” looks awful, i want to append the “size”, instead of prepending it, which would make it “icon_size”. But i don’t know how to do that. Can anyone help?