use of com.oracle.truffle.llvm.runtime.LLVMSymbol in project graal by oracle.
the class LLSourceMap method getGlobalScope.
private LLVMSourceLocation getGlobalScope(LLVMScope moduleScope) {
if (globalScope == null) {
globalScope = LLVMSourceLocation.createLLModule(llSource.getName(), llSource.createSection(0, llSource.getLength()));
}
if (!globals.isEmpty()) {
for (String globalName : globals) {
assert globalName.startsWith("@");
final LLVMSymbol actualSymbol = moduleScope.get(globalName.substring(1));
if (actualSymbol != null && actualSymbol.isGlobalVariable()) {
globalScope.addGlobal(actualSymbol.asGlobalVariable());
} else {
LLVMGlobal global = LLVMGlobal.createUnavailable(globalName);
globalScope.addGlobal(global);
}
}
globals.clear();
}
return globalScope;
}
use of com.oracle.truffle.llvm.runtime.LLVMSymbol in project graal by oracle.
the class LLVMDLSym method doDefaultHandle.
@Specialization(guards = "isRtldDefault(libraryHandle)")
protected Object doDefaultHandle(@SuppressWarnings("unused") LLVMNativePointer libraryHandle, @SuppressWarnings("unused") LLVMPointer symbolName, @SuppressWarnings("unused") @Cached() LLVMReadStringNode readStr, @Cached WrappedFunctionNode wrapper, @Cached BranchProfile exception) {
LLVMContext ctx = LLVMContext.get(this);
String name = readStr.executeWithTarget(symbolName);
LLVMSymbol symbol = ctx.getGlobalScopeChain().get(name);
if (symbol == null) {
Object nativeSymbol = getNativeSymbol(name, ctx);
if (nativeSymbol == null) {
ctx.setDLError(2);
return LLVMNativePointer.createNull();
}
return wrapper.execute(nativeSymbol);
}
return ctx.getSymbol(symbol, exception);
}
use of com.oracle.truffle.llvm.runtime.LLVMSymbol in project graal by oracle.
the class AllocExternalSymbolNode method lookupFromScope.
@TruffleBoundary
private static LLVMPointer lookupFromScope(LLVMScopeChain scope, LLVMSymbol symbol, LLVMContext context) {
LLVMSymbol resultSymbol = scope.get(symbol.getName());
if (resultSymbol == null) {
return null;
}
LLVMPointer pointer = context.getSymbolUncached(LLVMAlias.resolveAlias(resultSymbol));
context.registerSymbol(symbol, pointer);
return pointer;
}
use of com.oracle.truffle.llvm.runtime.LLVMSymbol in project graal by oracle.
the class InitializeSymbolsNode method allocGlobals.
private void allocGlobals(LLVMContext context, LLVMPointer roBase, LLVMPointer rwBase) {
for (int i = 0; i < globals.length; i++) {
LLVMSymbol allocGlobal = globals[i];
LLVMGlobal descriptor = fileScope.getGlobalVariable(allocGlobal.getName());
if (descriptor == null) {
exception.enter();
throw new LLVMLinkerException(this, "Global variable %s not found", allocGlobal.getName());
}
if (!context.checkSymbol(allocGlobal)) {
// because of our symbol overriding support, it can happen that the global was
// already bound before to a different target location
LLVMPointer ref;
if (globalOffsets[i] == -1) {
ref = LLVMManagedPointer.create(new LLVMGlobalContainer());
} else {
LLVMPointer base = globalIsReadOnly[i] ? roBase : rwBase;
ref = base.increment(globalOffsets[i]);
}
context.initializeSymbol(globals[i], ref);
List<LLVMSymbol> list = new ArrayList<>(1);
list.add(descriptor);
context.registerSymbolReverseMap(list, ref);
}
}
}
use of com.oracle.truffle.llvm.runtime.LLVMSymbol in project graal by oracle.
the class LLVMParser method defineAlias.
private void defineAlias(String existingName, String newName, boolean newExported) {
// handle the file scope
LLVMSymbol aliasTarget = runtime.lookupSymbol(existingName);
LLVMAlias aliasSymbol = new LLVMAlias(newName, aliasTarget, newExported);
runtime.getFileScope().register(aliasSymbol);
registerInPublicFileScope(aliasSymbol);
}
Aggregations