From 135537af3501d8676c7b6ad1bee2f8a51f7b0ca2 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 4 Oct 2020 09:52:15 +0000 Subject: added example dlopen-able libhack.c and updated Makefile to actually be able to build segfault. was missing -ldl --- Makefile | 12 ++++++++---- libhack.c | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 libhack.c diff --git a/Makefile b/Makefile index 56eb231..4e755c7 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ -LDFLAGS=-L/usr/local/lib -L/home/pi/.local/lib -lirc -lhashtable -lgcc_s -lidc -CFLAGS=-pedantic -Wall -ggdb -I/usr/local/include -I/home/pi/.local/include +PREFIX:=/usr/local +LDFLAGS=-L/usr/local/lib -L$(PREFIX)/lib -lirc -lhashtable -lgcc_s -lidc -ldl +CFLAGS=-pedantic -Wall -ggdb -I/usr/local/include -I$(PREFIX)/include -all: segfault +all: segfault libhack.so + +libhack.so: libhack.o + ld -shared -o libhack.so libhack.o again: clean all -segfault: segfault.c +segfault: segfault.c access.h clean: rm -f segfault diff --git a/libhack.c b/libhack.c new file mode 100644 index 0000000..b17e380 --- /dev/null +++ b/libhack.c @@ -0,0 +1,8 @@ +#include +#include + +#define mywrite(a,b) write(a,b,strlen(b)) + +void c_hack(int fd,char *from,char *line,...) { + mywrite(fd,"PRIVMSG #cmd :lol. this is in a shared library.\r\n"); +} -- cgit v1.2.3