Commit 3e551b3c by Nicolas Capens Committed by Nicolas Capens

Work around LLVM ORCv2 issue affecting Cuttlefish

Android Cuttlefish x86 instances crashed with an execution privilege access violation error, due to an R_386_PC32 relocation which is used when calling a C function from Reactor code, who's address is not associated with any symbol (since it's an absolute constant), but it still invokes the symbol resolver for "". Returning any address for this nameless symbol prevents the issue. This is not a proper fix for the root cause, which is presumed to be a bug in LLVM's handling of ELF::R_386_PC32 relocations not associated with any symbol, but it enables us to make the switch from the deprecated LLVM ORCv1 JIT API to ORCv2. Bug: b/172974501 Change-Id: I2d1978fccd2365bd8837f6d2054f43792f61cf73 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50368 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarJason Macnak <natsu@google.com> Reviewed-by: 's avatarJason Macnak <natsu@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 8dceaddf
......@@ -497,6 +497,13 @@ class ExternalSymbolGenerator : public llvm::orc::JITDylib::DefinitionGenerator
functions.try_emplace("sync_fetch_and_min_4", reinterpret_cast<void *>(sync_fetch_and_min_4));
functions.try_emplace("sync_fetch_and_umax_4", reinterpret_cast<void *>(sync_fetch_and_umax_4));
functions.try_emplace("sync_fetch_and_umin_4", reinterpret_cast<void *>(sync_fetch_and_umin_4));
# if defined(__i386__)
// TODO(b/172974501): Workaround for an x86-32 issue where an R_386_PC32 relocation is used
// When calling a C function from Reactor code, who's address is not associated with any symbol
// (since it's an absolute constant), but it still invokes the symbol resolver for "".
functions.try_emplace("", nullptr);
# endif
#endif
#if __has_feature(memory_sanitizer)
functions.try_emplace("msan_unpoison", reinterpret_cast<void *>(__msan_unpoison)); // TODO(b/155148722): Remove when we no longer unpoison all writes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment