From addd24134ea3b3b73b9a21e2d82b4962c9b5b3c9 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sat, 27 Mar 2021 23:52:08 +0100 Subject: [PATCH] libexecinfo recipe --- recipes/libexecinfo/10-execinfo.patch | 64 +++++++++++++++++++ .../libexecinfo/20-define-gnu-source.patch | 24 +++++++ recipes/libexecinfo/30-linux-makefile.patch | 44 +++++++++++++ recipes/libexecinfo/Makefile | 20 ++++++ 4 files changed, 152 insertions(+) create mode 100644 recipes/libexecinfo/10-execinfo.patch create mode 100644 recipes/libexecinfo/20-define-gnu-source.patch create mode 100644 recipes/libexecinfo/30-linux-makefile.patch create mode 100644 recipes/libexecinfo/Makefile diff --git a/recipes/libexecinfo/10-execinfo.patch b/recipes/libexecinfo/10-execinfo.patch new file mode 100644 index 0000000..44db530 --- /dev/null +++ b/recipes/libexecinfo/10-execinfo.patch @@ -0,0 +1,64 @@ +--- a/execinfo.c.orig ++++ b/execinfo.c +@@ -69,7 +69,8 @@ + char ** + backtrace_symbols(void *const *buffer, int size) + { +- int i, clen, alen, offset; ++ size_t clen, alen; ++ int i, offset; + char **rval; + char *cp; + Dl_info info; +@@ -78,7 +79,6 @@ + rval = malloc(clen); + if (rval == NULL) + return NULL; +- (char **)cp = &(rval[size]); + for (i = 0; i < size; i++) { + if (dladdr(buffer[i], &info) != 0) { + if (info.dli_sname == NULL) +@@ -92,14 +92,14 @@ + 2 + /* " <" */ + strlen(info.dli_sname) + /* "function" */ + 1 + /* "+" */ +- D10(offset) + /* "offset */ ++ 10 + /* "offset */ + 5 + /* "> at " */ + strlen(info.dli_fname) + /* "filename" */ + 1; /* "\0" */ + rval = realloc_safe(rval, clen + alen); + if (rval == NULL) + return NULL; +- snprintf(cp, alen, "%p <%s+%d> at %s", ++ snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s", + buffer[i], info.dli_sname, offset, info.dli_fname); + } else { + alen = 2 + /* "0x" */ +@@ -108,12 +108,15 @@ + rval = realloc_safe(rval, clen + alen); + if (rval == NULL) + return NULL; +- snprintf(cp, alen, "%p", buffer[i]); ++ snprintf((char *) rval + clen, alen, "%p", buffer[i]); + } +- rval[i] = cp; +- cp += alen; ++ rval[i] = (char *) clen; ++ clen += alen; + } + ++ for (i = 0; i < size; i++) ++ rval[i] += (long) rval; ++ + return rval; + } + +@@ -155,6 +158,6 @@ + return; + snprintf(buf, len, "%p\n", buffer[i]); + } +- write(fd, buf, len - 1); ++ write(fd, buf, strlen(buf)); + } + } diff --git a/recipes/libexecinfo/20-define-gnu-source.patch b/recipes/libexecinfo/20-define-gnu-source.patch new file mode 100644 index 0000000..7255ecd --- /dev/null +++ b/recipes/libexecinfo/20-define-gnu-source.patch @@ -0,0 +1,24 @@ +--- a/execinfo.c.orig ++++ b/execinfo.c +@@ -26,6 +26,7 @@ + * $Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $ + */ + ++#define _GNU_SOURCE + #include + #include + #include +--- a/stacktraverse.c.orig ++++ b/stacktraverse.c +@@ -1,3 +1,4 @@ ++#define _GNU_SOURCE + #include + + #include "stacktraverse.h" +--- a/test.c.orig ++++ b/test.c +@@ -1,3 +1,4 @@ ++#define _GNU_SOURCE + #include + #include + diff --git a/recipes/libexecinfo/30-linux-makefile.patch b/recipes/libexecinfo/30-linux-makefile.patch new file mode 100644 index 0000000..6bc8a89 --- /dev/null +++ b/recipes/libexecinfo/30-linux-makefile.patch @@ -0,0 +1,44 @@ +--- a/Makefile.orig ++++ b/Makefile +@@ -23,24 +23,25 @@ + # SUCH DAMAGE. + # + # $Id: Makefile,v 1.3 2004/07/19 05:19:55 sobomax Exp $ ++# ++# Linux Makefile by Matt Smith , 2011/01/04 + +-LIB= execinfo ++CC=cc ++AR=ar ++EXECINFO_CFLAGS=$(CFLAGS) -O2 -pipe -fno-strict-aliasing -std=gnu99 -fstack-protector -c ++EXECINFO_LDFLAGS=$(LDFLAGS) + +-SRCS= stacktraverse.c stacktraverse.h execinfo.c execinfo.h ++all: static dynamic + +-INCS= execinfo.h ++static: ++ $(CC) $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) stacktraverse.c ++ $(CC) $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) execinfo.c ++ $(AR) rcs libexecinfo.a stacktraverse.o execinfo.o + +-SHLIB_MAJOR= 1 +-SHLIB_MINOR= 0 ++dynamic: ++ $(CC) -fpic -DPIC $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) stacktraverse.c -o stacktraverse.So ++ $(CC) -fpic -DPIC $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) execinfo.c -o execinfo.So ++ $(CC) -shared -Wl,-soname,libexecinfo.so.1 -o libexecinfo.so.1 stacktraverse.So execinfo.So + +-NOPROFILE= yes +- +-DPADD= ${LIBM} +-LDADD= -lm +- +-#WARNS?= 4 +- +-#stacktraverse.c: gen.py +-# ./gen.py > stacktraverse.c +- +-.include ++clean: ++ rm -rf *.o *.So *.a *.so diff --git a/recipes/libexecinfo/Makefile b/recipes/libexecinfo/Makefile new file mode 100644 index 0000000..bf34325 --- /dev/null +++ b/recipes/libexecinfo/Makefile @@ -0,0 +1,20 @@ +name = libexecinfo +version = 1.1 + +URL = http://distcache.freebsd.org/local-distfiles/itetcu/libexecinfo-$(version).tar.bz2 +patches = 10-execinfo.patch 20-define-gnu-source.patch 30-linux-makefile.patch + +fake_root_install_backend = fake_root_install_custom + +SYSCONF ?= ../../ +include $(SYSCONF)/package.mk + +CFLAGS += -fno-omit-frame-pointer +export CFLAGS + +fake_root_install_custom: + install -D -m755 $(bdir)/execinfo.h $(pkg_fake_root_dir)/$(PREFIX)/include/execinfo.h + install -D -m755 $(bdir)/stacktraverse.h $(pkg_fake_root_dir)/$(PREFIX)/include/stacktraverse.h + install -D -m755 $(bdir)/libexecinfo.a $(pkg_fake_root_dir)/$(PREFIX)/lib/libexecinfo.a + install -D -m755 $(bdir)/libexecinfo.so.1 $(pkg_fake_root_dir)/$(PREFIX)/lib/libexecinfo.so.1 + ln -s $(PREFIX)/lib/libexecinfo.so.1 $(pkg_fake_root_dir)/$(PREFIX)/lib/libexecinfo.so