Linking OpenSSL engine with a third party dynamic library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
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: libuthread.so

libuthread.so: $(OBJ)
        $(LD) -shared -o $(@) $(OBJ)

clean:
        rm -f *.o *.d libuthread.so

-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 librsa_engine.so -L./libdune rsa-engine.o rsa/rsa.o rsa/bignum.o rsa/aes.o -Wl,-Bstatic -ldune -Wl,-Bdynamic -lcrypto -luthread
mv librsa_engine.so rsa-engine-new.so

4. After compilation, $ldd rsa-engine-new.so  shows the following,
 
linux-vdso.so.1 =>  (0x00007ffded367000)
libcrypto.so.1.1 => /opt/openssl/lib/libcrypto.so.1.1 (0x00007f895c5fa000)
libuthread.so => /lib/x86_64-linux-gnu/libuthread.so (0x00007f895c3f4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f895c02a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f895be26000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f895bc09000)
/lib64/ld-linux-x86-64.so.2 (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 wrong? 
N.B: I checked the library with a simple program and the library works fine. 

Thanks,
Shariful

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux