Linking OpenSSL engine with a third party dynamic library

Shariful Alam dipto181 at
Tue Apr 12 18:31:06 UTC 2022

I have a custom OpenSSL engine and it is working fine with pthread. I was
trying to use a third-party thread library
<> by linking this library with my
engine. However, upon linking and running the engine, I'm getting a
Segmentation fault. I just could not figure out why. I have a hunch that my
linking with the newly built dynamic library is not correct,

Following is what I did
1. Compile the thread library as a dynamic library

CC      = gcc
CFLAGS  = -Wall -fPIC -g -O3 -MD
LDFLAGS = -shared
OBJ     = uthread.o

all: $(OBJ)

        $(LD) -shared -o $(@) $(OBJ)


        rm -f *.o *.d

-include *.d

%.o: %.c

        $(CC) $(CFLAGS) -o $@ -c $<

2. Copy this library to */lib/x86_64-linux-gnu/*
3. My Make file to compile my OpenSSL engine

*gcc -g -fPIC -c -fomit-frame-pointer rsa-engine.c*
*gcc -g -shared -o -L./libdune rsa-engine.o rsa/rsa.o
rsa/bignum.o rsa/aes.o -Wl,-Bstatic -ldune -Wl,-Bdynamic -lcrypto -luthread*


4. After compilation, $*ldd*  shows the following, =>  (0x00007ffded367000) => /opt/openssl/lib/ (0x00007f895c5fa000) => /lib/x86_64-linux-gnu/ (0x00007f895c3f4000) => /lib/x86_64-linux-gnu/ (0x00007f895c02a000) => /lib/x86_64-linux-gnu/ (0x00007f895be26000) => /lib/x86_64-linux-gnu/
/lib64/ (0x00007f895cd56000)

I use gdb to find out what causes the segmentation fault, I find out
that *uthread_join(),
*is failing at some point. Can someone please tell me what I'm, doing
N.B: I checked the library with a simple program and the library works

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the openssl-users mailing list