Coder Social home page Coder Social logo

Comments (7)

rui314 avatar rui314 commented on July 18, 2024 1

@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.

rui314 avatar rui314 commented on July 18, 2024

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.

pacak avatar pacak commented on July 18, 2024

from mold.

rui314 avatar rui314 commented on July 18, 2024

Yeah, it's great if you can reproduce the issue in a Docker.

from mold.

nehaljwani avatar nehaljwani commented on July 18, 2024

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.

nehaljwani avatar nehaljwani commented on July 18, 2024

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.

pacak avatar pacak commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.