Skip to content

Instantly share code, notes, and snippets.

@chris-se
chris-se / build.sh
Created June 24, 2022 11:34
rpath interaction with ld.so and dlopen example
#!/bin/sh
set -xe
gcc -fPIC -Wall -shared -Wl,-soname,libtest3.so.0 -o libtest3/libtest3.so.0 libtest3/libtest3.c
gcc -fPIC -Wall -shared -Wl,-soname,libtest2.so.0 -o libtest2/libtest2.so.0 libtest2/libtest2.c
gcc -fPIC -Wall -shared -Wl,-soname,libtest1.so.0 -o libtest1/libtest1.so.0 libtest1/libtest1.c libtest2/libtest2.so.0 -ldl
gcc -fPIC -Wall -o prog/prog prog/main.c -Wl,-rpath-link,libtest2 -Wl,-rpath,$PWD/libtest1:$PWD/libtest2:$PWD/libtest3 libtest1/libtest1.so.0
# - Calling prog/prog won't work because library not found
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <pthread.h>
#include <liburing.h>
static pthread_mutex_t submit_mutex = PTHREAD_MUTEX_INITIALIZER;
static struct io_uring ring;
diff --git a/Makefile.in b/Makefile.in
index ba953be..e745972 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -28,7 +28,7 @@ else
BUILD_STATIC = $(ENABLE_STATIC)
endif
ifeq ($(HAVE_LD_VERSION_SCRIPT),1)
-SOLIB_VERSION_OPTS = -Wl,--version-script=libisns.vers
+SOLIB_VERSION_OPTS = -Wl,--version-script=$(srcdir)/libisns.vers
From 15c5afe4cd174dd067280a8bccc378f6ce58aa6b Mon Sep 17 00:00:00 2001
From: Christian Seiler <[email protected]>
Date: Tue, 3 Jan 2017 09:20:43 +0100
Subject: [PATCH] Add support for musl-libc (endian.h)
musl supports the soon-to-be standardized endian.h, while FreeBSD only
supports sys/endian.h as of now, so check for FreeBSD here, as other
operating systems will likely support endian.h in the future.
Signed-off-by: Christian Seiler <[email protected]>
Index: lib/strcpy.c
===================================================================
RCS file: /cvs/dietlibc/lib/strcpy.c,v
retrieving revision 1.5
diff -u -p -r1.5 strcpy.c
--- lib/strcpy.c 19 Feb 2008 00:28:13 -0000 1.5
+++ lib/strcpy.c 4 Apr 2016 20:49:53 -0000
@@ -3,6 +3,10 @@
#include "dietfeatures.h"
#include "dietstring.h"
Index: libstdio/fflush.c
===================================================================
RCS file: /cvs/dietlibc/libstdio/fflush.c,v
retrieving revision 1.22
diff -u -p -r1.22 fflush.c
--- libstdio/fflush.c 19 Jun 2012 12:53:48 -0000 1.22
+++ libstdio/fflush.c 22 Mar 2016 19:12:57 -0000
@@ -17,7 +17,6 @@ int fflush_unlocked(FILE *stream) {
if (stream==0) {
int res;
Index: x86_64/__testandset.S
===================================================================
RCS file: /cvs/dietlibc/x86_64/__testandset.S,v
retrieving revision 1.3
diff -u -p -r1.3 __testandset.S
--- x86_64/__testandset.S 25 Jan 2016 19:04:48 -0000 1.3
+++ x86_64/__testandset.S 7 Feb 2016 00:31:29 -0000
@@ -9,7 +9,5 @@
__testandset:
xorl %eax,%eax