ladybird/Userland/Libraries
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
..
LibArchive Everywhere: Use my cool new @serenityos.org email address 2021-09-01 11:37:25 +04:30
LibAudio Audio: Add per-client volume 2021-09-12 23:38:57 +02:00
LibC Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
LibCards LibGfx: Use "try_" prefix for static factory functions 2021-07-21 18:02:15 +02:00
LibChess LibChess: Fix hashing of the chess board 2021-07-30 20:49:18 +02:00
LibCompress LibCompress: Discard GZip NAME & COMMENT optional strings 2021-05-18 08:09:21 +02:00
LibConfig ConfigServer+LibConfig: Add way for clients to listen for config changes 2021-08-26 23:41:38 +02:00
LibCore LibCore: Add a Socket::set_idle() API that turns the notifiers on/off 2021-10-04 15:31:26 +02:00
LibCoredump LibCoredump: Don't copy uncompressed coredumps into a ByteBuffer 2021-09-22 00:40:07 +02:00
LibCpp LibCpp: Remove redundant comparison to Token::Type::PipePipe 2021-09-28 10:58:09 +02:00
LibCrypt Everywhere: Use my cool new @serenityos.org email address 2021-09-01 11:37:25 +04:30
LibCrypto Libraries: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
LibDebug LibDebug: Add missing break in AddressRanges::for_each_range() 2021-09-28 18:05:42 +02:00
LibDesktop Userland: Use Core::Process::spawn() instead of posix_spawn() in places 2021-08-06 01:06:42 +02:00
LibDiff LibDiff: Coalesce adjacent changes into the same Hunk 2021-09-24 14:32:52 +02:00
LibDl Toolchain+Userland: Enable TLS for x86_64 2021-07-04 01:07:28 +02:00
LibDSP LibDSP: Remove unused Effects::Delay::m_old_delay_size member 2021-09-28 10:58:09 +02:00
LibELF LibELF: Fix dynamic linking of dlopen()-ed libs 2021-10-06 12:33:21 +02:00
LibFileSystemAccessClient LibFileSystemAccessClient: Convert request paths to absolute if needed 2021-09-10 20:46:50 +04:30
LibGemini LibHTTP+LibGemini: Set underlying sockets as idle when detaching 2021-10-04 15:31:26 +02:00
LibGfx Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
LibGL LibGL: Remove duplicate GLboolean typedef 2021-10-02 21:10:13 +01:00
LibGUI LibGUI: Implement automatic scrolling in AbstractView 2021-09-29 23:58:55 +02:00
LibHTTP LibHTTP: Bump max HTTP header size up to 32KiB 2021-10-04 18:26:16 +02:00
LibImageDecoderClient Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibIMAP LibIMAP: Remove unused Variant option 2021-09-21 04:22:52 +04:30
LibIPC LibIPC: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
LibJS LibJS: Make escape_regexp_pattern() a RegExpObject member function 2021-10-05 18:35:49 +01:00
LibKeyboard AK: Make Utf8View constructors inline and remove C string constructor 2021-09-18 19:54:24 +02:00
LibLine Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
LibM Libraries: Fix typos 2021-10-01 01:06:40 +01:00
LibMarkdown LibMarkdown: Add start numbers for ordered lists 2021-10-05 13:27:25 +03:30
LibPCIDB Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
LibPDF LibPDF: Rely on default-constructor of Variant 2021-09-21 04:22:52 +04:30
LibProtocol RequestServer+LibProtocol: Add an 'EnsureConnection' IPC endpoint 2021-09-28 22:32:31 +02:00
LibPthread LibPthread: Correct nonsensical loop exit condition in RWLock unlock 2021-09-28 12:34:51 +03:30
LibRegex LibRegex: Use a match table for character classes 2021-10-03 19:16:36 +02:00
LibSanitizer LibSanitizer+AK: Add float cast overflow handler 2021-08-08 10:55:36 +02:00
LibSQL LibSQL: Allow expressions and column names in SELECT ... FROM 2021-10-05 02:22:19 +02:00
LibSymbolication LibSymbolication+SystemMonitor: Show ELF object in stack 2021-09-30 00:51:08 +02:00
LibSyntax LibSyntax: Fix bug in matching cursor highlighting 2021-09-03 11:45:50 +02:00
LibSystem Kernel+LibSystem: Add a 4th syscall argument 2021-07-25 14:08:50 +02:00
LibTest LibJS: Convert Object::get() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
LibTextCodec LibTextCodec: Ignore BYTE ORDER MARK at the start of utf8/16 strings 2021-09-15 17:00:18 +02:00
LibThreading LibThreading: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
LibTLS LibTLS: Split large application data packets into chunks 2021-10-03 14:42:00 +03:30
LibUnicode LibUnicode: Add some data related to currency codes 2021-09-11 11:05:50 +01:00
LibUSBDB LibUSBDB: Fix vendor id decoding 2021-06-18 19:41:25 +04:30
LibVideo Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
LibVT LibVT: Implement G0..G3 and VT100 translation table 2021-10-02 21:07:47 +01:00
LibWasm Libraries: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
LibWeb LibWeb: Fire MediaQueryListEvents when an MQL's match-state changes 2021-10-05 18:51:39 +02:00
LibWebSocket LibTLS: Use a setter for on_tls_ready_to_write with some more smarts 2021-09-19 21:10:23 +04:30
LibX86 LibX86: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
CMakeLists.txt Libraries: Add LibDSP 2021-08-31 17:03:55 +04:30