Skip to content

Instantly share code, notes, and snippets.

@o11c
Last active November 3, 2015 19:30
Show Gist options
  • Select an option

  • Save o11c/05775e1af61ee8936257 to your computer and use it in GitHub Desktop.

Select an option

Save o11c/05775e1af61ee8936257 to your computer and use it in GitHub Desktop.
# Make sure the indentation is tabs
override CC += -fPIE
override LDFLAGS += -pie
all: foo
file $<
nm *.o
foo: foo.o
foo.o: foo.c
foo.c: FORCE
echo '#include <stdio.h>' > $@
echo 'int main() { puts("Hello, World!"); }' >> $@
FORCE:
echo '#include <stdio.h>' > foo.c
echo 'int main() { puts("Hello, World!"); }' >> foo.c
cc -fPIE -c -o foo.o foo.c
cc -fPIE -pie foo.o -o foo
file foo
foo: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=70891543e59184ab2045c33e3f2ff5bc96dc292f, not stripped
nm *.o
U _GLOBAL_OFFSET_TABLE_
0000000000000000 T main
U puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment