llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.63k stars 11.83k forks source link

wasm-ld: crash when creating map file with Free Pascal generated object files #48316

Open nickysn opened 3 years ago

nickysn commented 3 years ago
Bugzilla Link 48972
Version unspecified
OS Linux
Attachments Object modules and linker script to reproduce the crash
CC @dschuff,@sbc100

Extended Description

Linker crashes, when asked to create a map file. It produces a working WebAssembly binary when not creating a map file. The WebAssembly binary targets the WASI platform and can be run using wasmtime.

Object modules being linked are produced by the llvm-mc assembler. Assembly output that was previously fed to llvm-mc was generated by the Free Pascal Compiler.

I have attached all the object modules and two linker scripts - one that invokes the linker without map file (this one produces a working WebAssembly binary), and one that tries to create a map file, which causes a crash. The linker scripts are exactly as produced by the Free Pascal Compiler and use absolute paths to the linker binary, which needs to be adjusted for your system.

I have included the source code for the Pascal program that was compiled (hello.pas). This gives information of how a successful hello.wasm should behave. It demonstrates that standard input and output are working and needs no file access.

I have not included the assembler files, produced by the Free Pascal compiler, but I can provide them as well, if that would help resolve the bug. They are quite big. The assembly source for producing system.o alone is enough to reach the 1 MB bugzilla attachment limit after gzipping.

The llvm-mc and wasm-ld linkers are compiled from the git main branch, commit 689de5841c1c4c9b0fe711b61d26f7425cf99423.

The crash looks like this:

Linking hello.wasm PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. ./link-linkmap.sh: line 10: 30785 Segmentation fault (core dumped) /home/nickysn/tralala/llvm/llvm-project/build-lld/bin/wasm-ld system.o hello.o si_prc.o --gc-sections -Map hello.map -o hello.wasm --no-entry --strip-all An error occurred while linking hello.wasm

nickysn commented 3 years ago

I rebuilt with git main, commit df1a17c219c073427f9d00eb042057bb3a4a3c64 and retested with the same files (attached to this bug report) and it is still crashing. :(

sbc100 commented 3 years ago

Can this now be closed?

sbc100 commented 3 years ago

I wonder if this will be fixed by this change when it lands: https://reviews.llvm.org/D88369