i.MX6UL: How to use LD_PRELOAD to override connect function of socket library?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX6UL: How to use LD_PRELOAD to override connect function of socket library?

705 Views
TammyTsai
Contributor III

Hi NXP team,

When root executes the "app1" program, app1 will execute "su ap -c app2" to run the "app2" program.

P.S. ap is a normal user.

Originally, app2 calls the connect function from the socket library.

Now, I want to set the LD_PRELOAD environment variable to point to a shared object file that contains a custom implementation of connect, and the custom implementation of connect will be called when the "app2" program is executed.

I create a file called ssl_winsock.c that provides a custom implementation of the connect function.

This implementation of connect simply outputs a message. (Just want to make sure this custom function will be called.)

Next, I compile ssl_winsock.c into a shared object file using the gcc compiler.

$ gcc -shared -fPIC -o libsock.so ssl_winsock.c

I use LD_PRELOAD to override the connect function in a program.

Preload libsock.so and run the "app1" program.

# LD_PRELOAD=~/libsock.so; ./app1

Ultimately, the custom implementation of connect provided in libsock.so was not called.

Is there anything wrong?

0 Kudos
Reply
4 Replies

675 Views
brian14
NXP TechSupport
NXP TechSupport

Hi @TammyTsai

Thank you for contacting NXP Support!

It seems that this is a software issue.
I think you can try reporting this issue in a specialized software forum.
On the other hand, it could be an issue with the specific BSP version. Could you please give more details about your BSP version?

Additionally, you can test your process on another Linux machine, for example in a desktop.

0 Kudos
Reply

610 Views
TammyTsai
Contributor III

Hi @brian14 ,

Our BSP version is "Linux imx6ulevk 4.14.98-2.3.1+g860ec89b125a".

0 Kudos
Reply

595 Views
brian14
NXP TechSupport
NXP TechSupport

Hi @TammyTsai,

Thank you for your reply.

I will check if there are any reported issues with that BSP version.
About my last reply, have you tried to replicate the process on a desktop Linux machine?

0 Kudos
Reply

519 Views
TammyTsai
Contributor III

Hi @brian14 ,

Because our TCP connection issue has already resolved, I didn't replicate the LD_PRELOAD process on a desktop Linux machine.

Thank you for your help.

0 Kudos
Reply