Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix e_flags for 32-bit MIPS targets in generated object file #96930

Merged
merged 1 commit into from
May 13, 2022

Commits on May 11, 2022

  1. Fix e_flags for 32-bit MIPS targets in generated object file

    In rust-lang#95604 the compiler started generating a temporary symbols.o which is added
    to the linker invocation. This object file has an `e_flags` which may be invalid
    for 32-bit MIPS targets. Even though symbols.o doesn't contain code, linking
        with [lld fails](https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/MipsArchTree.cpp#L79) with
    ```
    rust-lld: error: foo-cgu.0.rcgu.o: ABI 'o32' is incompatible with target ABI 'n64'
    ```
    because it omits the ABI bits (EF_MIPS_ABI_O32) so lld assumes it's using the
    N64 ABI. This breaks linking on nightly for the out-of-tree [psx
    target](ayrtonm/psx-sdk-rs#9), the builtin
    mipsel-sony-psp target (cc @overdrivenpotato) and any other 32-bit MIPS
    target using lld.
    
    This PR sets the ABI in `e_flags` to O32 since that's the only ABI for 32-bit
    MIPS that LLVM supports. It also sets other `e_flags` bits based on the target.
    I had to bump the object crate version since some of these constants were [added
    recently](gimli-rs/object#433). I'm not sure if this
    PR needs a test, but I can confirm that it fixes the linking issue on both
    targets I mentioned.
    ayrtonm committed May 11, 2022
    Configuration menu
    Copy the full SHA
    3d5b1ee View commit details
    Browse the repository at this point in the history