Mark __dso_handle a "far" pointer:
The relocation needs to allow for long offsets, as for the JIT, __dso_handle might be outside the shared library. Fixes ``` cling JIT session error: In graph cling-module-10-jitted-objectbuffer, section __TEXT,__StaticInit: relocation target "___dso_handle" at address 0x7fe1ee5052e0 is out of range of Delta32 fixup at 0x108c410bd (___cxx_global_var_initcling_module_10_, 0x108c41090 + 0x2d) [runStaticInitializersOnce]: Failed to materialize symbols: { (main, { $.cling-module-10.__inits.0, __ZN12IncidentTypeL2m1E, __ZN6MarkerD2Ev, __ZN6MarkerD1Ev, ___cxx_global_var_initcling_module_10_.1, __GLOBAL__sub_I_cling_module_10, __ZN6MarkerC2EPKc, ___cxx_global_var_initcling_module_10_.3, __ZN12IncidentTypeL2m3E, __ZN6MarkerC1EPKc, __ZN12IncidentTypeL2m2E, ____orc_init_func.cling-module-10, ___cxx_global_var_initcling_module_10_ }) } ``` as seen no RISC-V and macOS, i.e. with the JITLinker.
This commit is contained in:
parent
89543f66cf
commit
76d96e317f
@ -88,6 +88,57 @@ namespace {
|
||||
|
||||
char KeepLocalGVPass::ID = 0;
|
||||
|
||||
namespace {
|
||||
class PreventLocalOptPass: public ModulePass {
|
||||
static char ID;
|
||||
|
||||
bool runOnGlobal(GlobalValue& GV) {
|
||||
if (!GV.isDeclaration())
|
||||
return false; // no change.
|
||||
|
||||
// GV is a declaration with no definition. Make sure to prevent any
|
||||
// optimization that tries to take advantage of the actual definition
|
||||
// being "local" because we have no influence on the memory layout of
|
||||
// data sections and how "close" they are to the code.
|
||||
|
||||
bool changed = false;
|
||||
|
||||
if (GV.hasLocalLinkage()) {
|
||||
GV.setLinkage(llvm::GlobalValue::ExternalLinkage);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!GV.hasDefaultVisibility()) {
|
||||
GV.setVisibility(llvm::GlobalValue::DefaultVisibility);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Set DSO locality last because setLinkage() and setVisibility() check
|
||||
// isImplicitDSOLocal().
|
||||
if (GV.isDSOLocal()) {
|
||||
GV.setDSOLocal(false);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public:
|
||||
PreventLocalOptPass() : ModulePass(ID) {}
|
||||
|
||||
bool runOnModule(Module &M) override {
|
||||
bool ret = false;
|
||||
for (auto &&F: M)
|
||||
ret |= runOnGlobal(F);
|
||||
for (auto &&G: M.globals())
|
||||
ret |= runOnGlobal(G);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
char PreventLocalOptPass::ID = 0;
|
||||
|
||||
namespace {
|
||||
class WeakTypeinfoVTablePass: public ModulePass {
|
||||
static char ID;
|
||||
@ -339,6 +390,7 @@ void BackendPasses::CreatePasses(llvm::Module& M, int OptLevel)
|
||||
m_MPM[OptLevel].reset(new legacy::PassManager());
|
||||
|
||||
m_MPM[OptLevel]->add(new KeepLocalGVPass());
|
||||
m_MPM[OptLevel]->add(new PreventLocalOptPass());
|
||||
m_MPM[OptLevel]->add(new WeakTypeinfoVTablePass());
|
||||
m_MPM[OptLevel]->add(new ReuseExistingWeakSymbols());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user