Comments (7)
@nehaljwani Thank you very much for the detailed instructions on how to reproduce the issue! With that, I could easily reproduce it and found the cause of the issue. The bug was a little bit surprising -- we haven't aligned the section header to a 4 or 8 byte boundaries until now. x86 isn't sensitive to data alignments, so it happened to work. The problem has been fixed.
from mold.
I created a new Rust project on my machine, copy-n-paste your code and build it with mold. I also built rust-analyzer with mold. But I couldn't reproduce the issue -- rust-analyzer analysis-stats .
works with and without mold. Is there more hidden conditions to reproduce the issue? Did you observe the same issue when building programs that are publicly available? (If so, I can try that too)
from mold.
from mold.
Yeah, it's great if you can reproduce the issue in a Docker.
from mold.
Steps to reproduce the problem:
# cat Cargo.toml
[package]
name = "dummy"
version = "0.0.0"
edition = "2018"
[dependencies]
object = { version = "0.25.3", default-features = false, features = ["read_core", "elf"] }
memmap2 = "0.3.0"
# cat src/main.rs
use std::env;
use std::fs::File;
use memmap2::MmapOptions;
use object::read::{File as BinaryFile};
fn main() {
let args: Vec<String> = env::args().collect();
let file = File::open(&args[1]).expect(":'(\t");
let mmap = unsafe { MmapOptions::new().map(&file).expect(":'(\t") };
BinaryFile::parse(&*mmap).expect(":(\t");
}
# ~/.cargo/bin/cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
# echo 'void foo() {};' | clang -xc - -fuse-ld=/root/mold/mold -shared -o libfoo.so
# ./target/debug/dummy /lib/x86_64-linux-gnu/libc.so.6
# echo $?
0
# ./target/debug/dummy $(readlink -f libfoo.so)
thread 'main' panicked at ':( : Error("Invalid ELF section header offset/size/alignment")', src/main.rs:11:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
# echo $?
101
from mold.
Update: If I add the "unaligned" feature to the object dependency, then it works. This is not present at https://github.com/rust-analyzer/rust-analyzer/search?l=TOML&q=object . I don't know why it works though.
from mold.
Let me know if an example above is working for you. If not - I'll try to make something in docker.
from mold.
Related Issues (20)
- Missing -z option rodynamic HOT 1
- riscv64-shared-abs-sym fails with 2.31.0 HOT 2
- Statically linked binaries crash with illegal hardware instructions HOT 7
- Cannot build project using tealr and Mold linker HOT 2
- `mold/third-party/mimalloc` can be bumped to `v2.1.6`
- Dependency file has references to temporary file HOT 8
- mold: fatal: unknown command line option: -arch HOT 1
- ninja error "FindFirstFileExA" during build on windows with vs2022 HOT 1
- Error with `cargo build --release` on PPC64LE: Missing `R_PPC64_TPREL16_LO_DS` HOT 2
- Is -z x86-64-vX supported? HOT 2
- Fails to build LLVM 18.1.6 with mold HOT 3
- Corrupts the `DWARF` section when relocating multiple objects into a single one HOT 3
- Feature request: Warn about reverse or cyclic dependencies
- MSYS2/UCRT64: LINKER_TYPE 'MOLD' is unknown or not supported by this toolchain. HOT 6
- Build mold from source with -march or -mcpu in the build script HOT 2
- mold support for Fortran HOT 1
- Segmentation fault when compiling ROOT HOT 4
- /usr/lib/mold/mold-wrapper.so: unsupported relocation type 1026 HOT 3
- Binary linked with mold segfaults immediately HOT 5
- [FEATURE REQ/BUG REP] SH4 endianas HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mold.