Skip to content

Instantly share code, notes, and snippets.

@sciolist
Created March 17, 2013 00:21
Show Gist options
  • Save sciolist/5178962 to your computer and use it in GitHub Desktop.
Save sciolist/5178962 to your computer and use it in GitHub Desktop.
Sectcreate
gcc -Os main.c -sectcreate __TEXT example example.txt
Hello, world.
#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