Files
clang-p2996/llvm/lib/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.cpp
Lang Hames e2eaf8ded7 [ORC] Force eh-frame use for older Darwins on x86-64 in MachOPlatform, LLJIT.
The system libunwind on older Darwins does not support JIT registration of
compact-unwind. Since the CompactUnwindManager utility discards redundant
eh-frame FDEs by default we need to remove the compact-unwind section first
when targeting older libunwinds in order to preserve eh-frames.

While LLJIT was already doing this as of eae6d6d18b, MachOPlatform was not.
This was causing buildbot failures in the ORC runtime (e.g. in
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3479/).

This patch updates both LLJIT and MachOPlatform to check a bootstrap value,
"darwin-use-ehframes-only", to determine whether to forcibly preserve
eh-frame sections. If this value is present and set to true then compact-unwind
sections will be discarded, causing eh-frames to be preserved. If the value is
absent or set to false then compact-unwind will be used and redundant FDEs in
eh-frames discarded (FDEs that are needed by the compact-unwind section are
always preserved).

rdar://143895614
2025-02-07 17:04:05 +11:00

37 lines
1.3 KiB
C++

//===----- DefaultHostBootstrapValues.cpp - Defaults for host process -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.h"
#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
#ifdef __APPLE__
#include <dlfcn.h>
#endif // __APPLE__
namespace llvm::orc {
void addDefaultBootstrapValuesForHostProcess(
StringMap<std::vector<char>> &BootstrapMap,
StringMap<ExecutorAddr> &BootstrapSymbols) {
// FIXME: We probably shouldn't set these on Windows?
BootstrapSymbols[rt::RegisterEHFrameSectionWrapperName] =
ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionWrapper);
BootstrapSymbols[rt::DeregisterEHFrameSectionWrapperName] =
ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionWrapper);
#ifdef __APPLE__
if (!dlsym(RTLD_DEFAULT, "__unw_add_find_dynamic_unwind_sections"))
BootstrapMap["darwin-use-ehframes-only"].push_back(1);
#endif // __APPLE__
}
} // namespace llvm::orc