mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
shared library loading in-mem
This commit is contained in:
@@ -9,15 +9,27 @@ let infile = files.open(infilePath)
|
||||
|
||||
const metaArea = sys.malloc(12)
|
||||
infile.pread(metaArea, 12, 0)
|
||||
let intent = sys.peek(metaArea+4) // 2 for executable, 3 for shared
|
||||
let addrToLoad = (sys.peek(metaArea+5) << 16) | (sys.peek(metaArea+6) << 8) | (sys.peek(metaArea+7))
|
||||
const imageSize = (sys.peek(metaArea+9) << 16) | (sys.peek(metaArea+10) << 8) | (sys.peek(metaArea+11))
|
||||
sys.free(metaArea)
|
||||
|
||||
|
||||
if (addrToLoad == 0)
|
||||
addrToLoad = sys.malloc(imageSize + 4)
|
||||
else
|
||||
sys.forceAlloc(addrToLoad, imageSize + 4)
|
||||
|
||||
// if it's a shared library, put it into the global table
|
||||
if (3 == intent) {
|
||||
// create the table if it's not there
|
||||
if (!_G.SO)
|
||||
_G.SO = {}
|
||||
|
||||
let libname = exec_args[1].split("\\").last().substringBeforeLast(".")
|
||||
_G.SO[libname] = addrToLoad
|
||||
}
|
||||
|
||||
// writes IMAGE_SIZE and the BINARY_IMAGE directly to the memory
|
||||
infile.pread(addrToLoad, imageSize + 4, 8)
|
||||
infile.close()
|
||||
|
||||
@@ -835,7 +835,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
||||
score += contrastWeight(yALow, yBLow, deltaLow, 2)
|
||||
}
|
||||
|
||||
return score > 14.0
|
||||
return score > 4.0
|
||||
}
|
||||
|
||||
fun encodeIpf2(srcPtr: Int, destPtr: Int, width: Int, height: Int, channels: Int, hasAlpha: Boolean, pattern: Int) {
|
||||
|
||||
Reference in New Issue
Block a user