Skip to content

Misaligned pointer error message could be improved. #109997

Closed as not planned
Closed as not planned
@vext01

Description

@vext01

Edit(fmease): Add #![feature] to the code example.

When we updated our Rust nightly, and compiled this (elided) code:

#![feature(link_llvm_intrinsics)]

/// The `llvm.embedded.module` symbol in the `.llvmbc` section.
#[repr(C)]
struct EmbeddedModule {
    /// The length of the bitcode.
    len: usize,
    /// The start of the bitcode itself.
    first_byte_of_bitcode: u8,
}

// ykllvm adds the `SHF_ALLOC` flag to the `.llvmbc` section so that the loader puts it into our
// address space at load time.
extern "C" {
    #[link_name = "llvm.embedded.module"]
    static LLVMBC: EmbeddedModule;
}

/// Returns a pointer to (and the size of) the raw LLVM bitcode in the current address space.
pub fn llvmbc_section() -> (*const u8, usize) {
    let bc = unsafe { &LLVMBC };
    (&bc.first_byte_of_bitcode as *const u8, bc.len)
}

'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x200b2d', ykutil/src/obj.rs:154:23

Where line 154 is:

let bc = unsafe { &LLVMBC };

There is no explicit (language-level) pointer deref on that line.

I wonder if the error message needs to be refined?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-linkageArea: linking into static, shared libraries and binariesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-internal-featuresThis issue requires the use of internal features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions