Created
March 17, 2013 00:21
-
-
Save sciolist/5178962 to your computer and use it in GitHub Desktop.
Sectcreate
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
gcc -Os main.c -sectcreate __TEXT example example.txt |
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
Hello, world. |
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
#include <stdio.h> | |
#include <mach-o/getsect.h> | |
int main(void) { | |
size_t size; | |
size_t slide = _dyld_get_image_vmaddr_slide(0); | |
const char *data = getsectdata("__TEXT", "example", &size); | |
printf("%.*s", (int) size, data + slide); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment