ladybird/Tests
Rodrigo Tobar 4b091a7cc2 LibELF: Fix dynamic linking of dlopen()-ed libs
Consider the situation where two shared libraries libA and libB, both
depending (as in having a NEEDED dtag) on libC. libA is first
dlopen()-ed, which produces libC to be mapped and linked. When libB is
dlopen()-ed the DynamicLinker would re-map and re-link libC though,
causing any previous references to its old location to be invalid. And
if libA's PLT has been patched to point to libC's symbols, then any
further invocations to libA will cause the code to jump to a virtual
address that isn't mapped anymore, therefore causing a crash. This
situation was reported in #10014, although the setup was more convolved
in the ticket.

This commit fixes the issue by distinguishing between a main program
loading being performed by Loader.so, and a dlopen() call. The main
difference between these two cases is that in the former the
s_globals_objects maps is always empty, while in the latter it might
already contain dependencies for the library being dlopen()-ed. Hence,
when collecting dependencies to map and link, dlopen() should skip those
that are present in the global map to avoid the issue described above.

With this patch the original issue seen in #10014 is gone, with all
python3 modules (so far) loading correctly.

A unit test reproducing a simplified issue is also included in this
commit. The unit test includes the building of two dynamic libraries A
and B with both depending on libline.so (and B also depending on A); the
test then dlopen()s libA, invokes one its function, then does the same
with libB.
2021-10-06 12:33:21 +02:00
..
AK AK: Add a basic formatter for wchar_t 2021-10-03 11:13:50 +00:00
Kernel Kernel: Move x86 IO instructions code into the x86 specific folder 2021-10-01 12:27:20 +02:00
LibC Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
LibCompress Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibCore Tests: Remove all file(GLOB) from CMakeLists in Tests 2021-09-02 09:08:23 +02:00
LibCpp Tests: Remove all file(GLOB) from CMakeLists in Tests 2021-09-02 09:08:23 +02:00
LibCrypto Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibELF LibELF: Fix dynamic linking of dlopen()-ed libs 2021-10-06 12:33:21 +02:00
LibGfx Tests: Conform font tests to new font format 2021-09-19 00:58:59 +02:00
LibIMAP Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibJS LibJS: Add a specific test for invalid unicode characters in the lexer 2021-10-03 17:42:05 +02:00
LibM Tests: Remove all file(GLOB) from CMakeLists in Tests 2021-09-02 09:08:23 +02:00
LibMarkdown Meta: Add Meta/CMake to the CMAKE_MODULE_PATH for Serenity and Lagom 2021-09-15 19:04:52 +04:30
LibPthread LibPthread: Add first test cases for RWlock 2021-09-28 18:36:20 +03:30
LibRegex LibRegex: Use a match table for character classes 2021-10-03 19:16:36 +02:00
LibSQL LibSQL: Add an INSERT without column names test 2021-10-04 15:51:48 +02:00
LibThreading Tests: Remove all file(GLOB) from CMakeLists in Tests 2021-09-02 09:08:23 +02:00
LibTLS LibTLS: Use a setter for on_tls_ready_to_write with some more smarts 2021-09-19 21:10:23 +04:30
LibUnicode LibUnicode+LibJS: Store locale keyword values as a single string 2021-09-08 21:08:48 +01:00
LibWasm Tests: Fix typos 2021-10-01 01:33:43 +01:00
LibWeb LibWeb: Rename HTMLDocumentParser => HTMLParser 2021-09-25 23:36:43 +02:00
UserspaceEmulator Tests: Remove all file(GLOB) from CMakeLists in Tests 2021-09-02 09:08:23 +02:00
CMakeLists.txt Tests: Test LibMarkdown against commonmark test suite 2021-08-31 16:53:51 +02:00