X | @kateinoigakukun |
---|---|
Mastodon | [email protected] |
in/kateinoigakukun |
kateinoigakukun / chibi-link Goto Github PK
View Code? Open in Web Editor NEWA toy linker for WebAssembly object files.
License: MIT License
A toy linker for WebAssembly object files.
License: MIT License
X | @kateinoigakukun |
---|---|
Mastodon | [email protected] |
in/kateinoigakukun |
I'm trying to modernize the object files used in PreviewSystem to use swift-wasm-5.3.1-RELEASE
toolchain and latest JavaScriptKit.
Linking a trivial object file with the prebuilt library fails at relocation.
Info: Reading obj.wasm
Warning: Custom section 'target_features' is currently not supported
Info: Reading library.so.wasm
Warning: Linking subsection 'comdatInfo' is not supported now
Warning: Custom section 'producers' is currently not supported
Debug: weak undef stub for _ZTH5errno is synthesized
Debug: weak undef stub for _swift_FORCE_LOAD_$_swiftWASILibc is synthesized
Debug: __start_swift5_typeref is synthesized
Debug: __stop_swift5_typeref is synthesized
Debug: __start_swift5_type_metadata is synthesized
Debug: __stop_swift5_type_metadata is synthesized
Debug: __start_swift5_reflstr is synthesized
Debug: __stop_swift5_reflstr is synthesized
Debug: __start_swift5_protocols is synthesized
Debug: __stop_swift5_protocols is synthesized
Debug: __start_swift5_protocol_conformances is synthesized
Debug: __stop_swift5_protocol_conformances is synthesized
Debug: __start_swift5_fieldmd is synthesized
Debug: __stop_swift5_fieldmd is synthesized
Debug: __start_swift5_entry is synthesized
Debug: __stop_swift5_entry is synthesized
Debug: __start_swift5_capture is synthesized
Debug: __stop_swift5_capture is synthesized
Debug: __start_swift5_builtin is synthesized
Debug: __stop_swift5_builtin is synthesized
Debug: __start_swift5_assocty is synthesized
Debug: __stop_swift5_assocty is synthesized
Debug: __start_.swift_modhash is synthesized
Debug: __stop_.swift_modhash is synthesized
Debug: __start_.swift1_autolink_entries is synthesized
Debug: __stop_.swift1_autolink_entries is synthesized
Debug: __start_.rodata is synthesized
Debug: __stop_.rodata is synthesized
Debug: __start_.note.swift_reflection_metadata is synthesized
Debug: __stop_.note.swift_reflection_metadata is synthesized
Debug: __start_.data is synthesized
Debug: __stop_.data is synthesized
Debug: __start_.bss is synthesized
Debug: __stop_.bss is synthesized
Debug: __dso_handle is synthesized
Debug: __stack_pointer is synthesized
Debug: Print all undefined symbols
Debug: fd_seek
Debug: fd_prestat_dir_name
Debug: path_remove_directory
Debug: swjs_get_subscript
Debug: swjs_call_function_with_this
Debug: __start_swift5_replac2
Debug: swjs_instanceof
Debug: fd_fdstat_set_flags
Debug: fd_read
Debug: $s10Foundation4UUIDVN
Debug: environ_sizes_get
Debug: swjs_decode_string
Debug: $s10Foundation4UUIDVACycfC
Debug: swjs_encode_string
Debug: __stop_swift5_replace
Debug: fd_close
Debug: path_readlink
Debug: args_sizes_get
Debug: path_create_directory
Debug: path_filestat_set_times
Debug: swjs_set_prop
Debug: fd_fdstat_get
Debug: fd_readdir
Debug: swjs_call_function
Debug: __stop_swift5_replac2
Debug: $s10Foundation4UUIDVs23CustomStringConvertibleAAMc
Debug: poll_oneoff
Debug: swjs_set_subscript
Debug: path_rename
Debug: swjs_load_string
Debug: path_open
Debug: $s10Foundation6BundleCMn
Debug: path_unlink_file
Debug: args_get
Debug: swjs_create_typed_array
Debug: proc_exit
Debug: __start_swift5_replace
Debug: fd_prestat_get
Debug: path_link
Debug: swjs_release
Debug: fd_write
Debug: $s10Foundation8TimeZoneV22abbreviationDictionarySDyS2SGvgZ
Debug: $s10Foundation3URLV14absoluteStringSSvg
Debug: $s10Foundation3URLVMn
Debug: swjs_call_throwing_new
Debug: environ_get
Debug: path_filestat_get
Debug: clock_time_get
Debug: swjs_get_prop
Debug: swjs_create_function
Debug: path_symlink
Debug: random_get
Debug: swjs_call_new
Debug: Writing type
Debug: Finish writing type
Debug: Writing import
Debug: Finish writing import
Debug: Writing function
Debug: Finish writing function
Debug: Writing table
Debug: Finish writing table
Debug: Writing memory
Debug: Finish writing memory
Debug: Writing global
Debug: Finish writing global
Debug: Writing export
Debug: Finish writing export
Debug: Writing elem
Debug: Finish writing elem
Debug: Writing code
Fatal error: file ChibiLink/Relocation.swift, line 156
2021-03-11 18:41:37.808576+0800 chibi-link[4359:10072536] Fatal error: file ChibiLink/Relocation.swift, line 156
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error
frame #0: 0x00007fff2ca79890 libswiftCore.dylib`_swift_runtime_on_report
frame #1: 0x00007fff2caf3ef3 libswiftCore.dylib`_swift_stdlib_reportFatalErrorInFile + 211
frame #2: 0x00007fff2c7837e5 libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 245
frame #3: 0x00007fff2c783427 libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 87
frame #4: 0x00007fff2c783a11 libswiftCore.dylib`function signature specialization <Arg[1] = [Closure Propagated : closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never, Argument Types : [Swift.StaticStringSwift.UnsafeBufferPointer<Swift.UInt8>Swift.UIntSwift.UInt32]> of generic specialization <()> of Swift.String.withUTF8<A>((Swift.UnsafeBufferPointer<Swift.UInt8>) throws -> A) throws -> A + 257
frame #5: 0x00007fff2c7820e7 libswiftCore.dylib`Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 519
* frame #6: 0x0000000100048471 chibi-link`Relocator.translate(relocation=ChibiLink.Relocation @ 0x00007ffeefbfcce8, binary=0x0000000107b0fc40, current=0, location=2935, self=0x000000010f9cdaf0) at Relocation.swift:156:17
frame #7: 0x000000010004b424 chibi-link`Relocator.apply(relocation=ChibiLink.Relocation @ 0x00007ffeefbfd6f8, sectionOffset=968, binary=0x0000000107b0fc40, bytes=8008 values, range=968..<5944, self=0x000000010f9cdaf0) at Relocation.swift:244:21
frame #8: 0x0000000100046c6c chibi-link`Relocator.relocate(chunk=8008 values, relocations=109 values, binary=0x0000000107b0fc40, range=968..<5944, sectionOffset=968, self=0x000000010f9cdaf0) at Relocation.swift:95:13
frame #9: 0x00000001000467c8 chibi-link`Relocator.relocate<T>(chunk=0x0000000107b0c070, self=0x000000010f9cdaf0) at Relocation.swift:81:9
frame #10: 0x000000010002bf19 chibi-link`OutputCodeSection.writeVectorContent(writer=0x000000010fab37d0, relocator=0x000000010f9cdaf0, self=0x000000010f9abd70) at OutputCodeSection.swift:27:34
frame #11: 0x000000010002c35a chibi-link`protocol witness for OutputVectorSection.writeVectorContent(writer:relocator:) in conformance OutputCodeSection at <compiler-generated>:0
frame #12: 0x000000010003e6ad chibi-link`OutputVectorSection.writeContent(writer=0x000000010fab37d0, relocator=0x000000010f9cdaf0, self=0x000000010f9abd70) at OutputSection.swift:38:13
frame #13: 0x000000010002c434 chibi-link`protocol witness for OutputSection.writeContent(writer:relocator:) in conformance OutputCodeSection at <compiler-generated>:0
frame #14: 0x000000010003e39e chibi-link`OutputSection.write(writer=0x000000010fab37d0, relocator=0x000000010f9cdaf0, self=0x000000010f9abd70) at OutputSection.swift:23:17
frame #15: 0x000000010002c3ed chibi-link`protocol witness for OutputSection.write(writer:relocator:) in conformance OutputCodeSection at <compiler-generated>:0
frame #16: 0x00000001000434c1 chibi-link`writeSection #1 <S>(section=0x000000010f9abd70, self=0x000000010fab3830, relocator=0x000000010f9cdaf0) in OutputWriter.writeBinary() at OutputWriter.swift:77:25
frame #17: 0x00000001000423c1 chibi-link`OutputWriter.writeBinary(self=0x000000010fab3830) at OutputWriter.swift:94:13
frame #18: 0x000000010002b036 chibi-link`performLinker(filenames=2 values, outputStream=(payload_data_0 = 0x0000000107b0f6c0 -> 0x0000000100076db0 type metadata for ChibiLink.FileOutputByteStream, payload_data_1 = 0x00000001001c0030 dyld`__block_descriptor_tmp, payload_data_2 = 0x00007ffeefbff360, instance_type = ChibiLink.FileOutputByteStream, witness_table_OutputByteStream = 0x0000000100072b38 chibi-link`protocol witness table for ChibiLink.FileOutputByteStream : ChibiLink.OutputByteStream in ChibiLink), exports=0 values) at Linker.swift:16:16
frame #19: 0x0000000100005523 chibi-link`main at main.swift:23:9
frame #20: 0x00007fff2039b621 libdyld.dylib`start + 1
frame #21: 0x00007fff2039b621 libdyld.dylib`start + 1
swift build --triple wasm32-unknown-wasi -c release
wasmtime run --mapdir /::./ .build/wasm32-unknown-wasi/release/chibi-link.wasm -- main.o lib.o -o main.wasm
Backtrace
$ wasminspect --mapdir /::./objects .build/wasm32-unknown-wasi/release/chibi-link.wasm
(wasminspect) process launch -- main.o lib.o -o main.wasm
Info: Reading main.o
Function exec failure out of bounds memory access, try to access 4294967296 but size of memory is 1179648
(wasminspect) bt
0: $s9ChibiLink12SymbolTargetOyAA04DataC0C14DefinedSegmentVAE09UndefinedG0VAE11SynthesizedVGWObTm
1: .L$s9ChibiLink12SymbolTargetOyAA04DataC0C14DefinedSegmentVAE09UndefinedG0VAE11SynthesizedVGWObTm_bitcast.52
2: $s9ChibiLink11SymbolTableC011addFunctionC0_5flagsAA0fC0CAA0C6TargetOyAA09IndexableH0VAA0F6ImportCAG11SynthesizedOG_AA0C5FlagsVtF
3: $s9ChibiLink0B13InfoCollectorC16onFunctionSymbolyySi_s6UInt32VSSSgSitFTf4dnnnn_n
4: $s9ChibiLink12BinaryReaderC15readSymbolTableyyFAA0B13InfoCollectorC_Tg5
5: $s9ChibiLink12BinaryReaderC18readLinkingSection11sectionSizeySi_tKFAA0B13InfoCollectorC_Tg5Tf4dn_n
6: $s9ChibiLink12BinaryReaderC17readCustomSection11sectionSizeySi_tKFAA0B13InfoCollectorC_Tg5Tf4dn_n
7: $s9ChibiLink12BinaryReaderC12readSectionsyyKFAA0B13InfoCollectorC_Tg5
8: $s9ChibiLink12BinaryReaderC10readModuleyyKFAA0B13InfoCollectorC_Tg5
9: $s9ChibiLink13performLinker_12outputStream7exportsySaySSG_AA010OutputByteF0_pAEtKF
10: main
11: main
12: __main_void
13: __original_main
14: _start
15: _start.command_export
(wasminspect)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.