Last active
January 10, 2023 10:32
-
-
Save dadevel/a2dad7d2e9d6db64bcbdb5d280dd50a1 to your computer and use it in GitHub Desktop.
C/C++ File Embedding
This file contains hidden or 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
| #include <stdio.h> | |
| # gcc ./embed.c -o ./embed && ./embed | |
| asm(R"( | |
| .pushsection .rodata | |
| .global flag | |
| .type flag, @object | |
| .balign 1 | |
| flag: | |
| .incbin "flag.txt" | |
| flag_end: | |
| .byte 0 | |
| .global flag_len | |
| .type flag_len, @object | |
| .balign 1 | |
| flag_len: | |
| .int flag_end - flag | |
| .popsection | |
| )"); | |
| extern char flag[]; | |
| extern int flag_len; | |
| int main() { | |
| printf("flag = %s; flag_len = %d\n", flag, flag_len); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment