Created
June 21, 2024 00:54
-
-
Save alexlnkp/f5c90594a1509c14b483644217cb24d2 to your computer and use it in GitHub Desktop.
Simple quine program in C using just the linker
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
#!/bin/bash | |
gcc -std=c17 -o main.o -c main.c | |
ld -r -b binary -o main.c.o main.c | |
gcc -o out main.o main.c.o | |
rm main.o | |
rm main.c.o | |
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> | |
extern char _binary_main_c_start[]; | |
extern char _binary_main_c_end[]; | |
int main(void) { | |
for (char* p = _binary_main_c_start; p != _binary_main_c_end; ++p) putchar( *p); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment