1*700637cbSDimitry Andric //===----- DefaultHostBootstrapValues.cpp - Defaults for host process -----===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric 
9*700637cbSDimitry Andric #include "llvm/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.h"
10*700637cbSDimitry Andric 
11*700637cbSDimitry Andric #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
12*700637cbSDimitry Andric #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
13*700637cbSDimitry Andric 
14*700637cbSDimitry Andric #ifdef __APPLE__
15*700637cbSDimitry Andric #include <dlfcn.h>
16*700637cbSDimitry Andric #endif // __APPLE__
17*700637cbSDimitry Andric 
18*700637cbSDimitry Andric namespace llvm::orc {
19*700637cbSDimitry Andric 
addDefaultBootstrapValuesForHostProcess(StringMap<std::vector<char>> & BootstrapMap,StringMap<ExecutorAddr> & BootstrapSymbols)20*700637cbSDimitry Andric void addDefaultBootstrapValuesForHostProcess(
21*700637cbSDimitry Andric     StringMap<std::vector<char>> &BootstrapMap,
22*700637cbSDimitry Andric     StringMap<ExecutorAddr> &BootstrapSymbols) {
23*700637cbSDimitry Andric 
24*700637cbSDimitry Andric   // FIXME: We probably shouldn't set these on Windows?
25*700637cbSDimitry Andric   BootstrapSymbols[rt::RegisterEHFrameSectionAllocActionName] =
26*700637cbSDimitry Andric       ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionAllocAction);
27*700637cbSDimitry Andric   BootstrapSymbols[rt::DeregisterEHFrameSectionAllocActionName] =
28*700637cbSDimitry Andric       ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionAllocAction);
29*700637cbSDimitry Andric 
30*700637cbSDimitry Andric #ifdef __APPLE__
31*700637cbSDimitry Andric   if (!dlsym(RTLD_DEFAULT, "__unw_add_find_dynamic_unwind_sections"))
32*700637cbSDimitry Andric     BootstrapMap["darwin-use-ehframes-only"].push_back(1);
33*700637cbSDimitry Andric #endif // __APPLE__
34*700637cbSDimitry Andric }
35*700637cbSDimitry Andric 
36*700637cbSDimitry Andric } // namespace llvm::orc
37