Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Linux Loader Lock / loader int __attribute__((constructor))

I am currently developing a program module called test.so. Inside this test.so, there is code that loads and uses an external library called wow.so.

To test this module, I created a new test project. The execution flow is as follows: Test program (main) → test.so → internally loads wow.so

Because test.so needs to automatically execute some code upon being loaded, I used a constructor function like this: static void __attribute__((constructor)) my_init() { ... }

However, this constructor function is not working properly.

After some research, I found that attempting to load another .so file using dlopen() within a constructor function can fail. This appears to be due to loader lock or the initialization order of dynamic libraries on Linux.

Furthermore, I do not have the source code or header files for wow.so; I only have the compiled .so file. Also, I must solve this issue by modifying only test.so — I cannot modify any other part.

Answer*

Draft saved
Draft discarded
Cancel

lang-c

AltStyle によって変換されたページ (->オリジナル) /