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

link_section attribute seems to be broken #27467

Closed
ababo opened this issue Aug 2, 2015 · 4 comments
Closed

link_section attribute seems to be broken #27467

ababo opened this issue Aug 2, 2015 · 4 comments

Comments

@ababo
Copy link

ababo commented Aug 2, 2015

I compile the code below:

#[link_section = ".multiboot_header"]
pub static MULTIBOOT_HEADER: multiboot::Header = multiboot::Header {
    magic: multiboot::HEADER_MAGIC,
    flags: HEADER_FLAGS,
    checksum: (-((multiboot::HEADER_MAGIC + HEADER_FLAGS) as i32) as u32),
    header_addr: 0,
    load_addr: 0,
    load_end_addr: 0,
    bss_end_addr: 0,
    entry_addr: 0,
    mode_type: 0,
    width: 0,
    height: 0,
    depth: 0
};

using compiler version 1.3.0-nightly (922aef0 2015-07-27) with the following command line:

rustc --crate-type rlib --target x86_64-unknown-linux-gnu -C opt-level=3 -C no-stack-check -Z no-landing-pads --cfg arch_x86_64 --sysroot /dev/null ...

As result I get the following symbol inside a produced rlib:

0000000000000000 g O .rodata._ZN4arch4boot16MULTIBOOT_HEADER20h86b23e12a2a05e14jaaE 0000000000000030 arch:: boot ::MULTIBOOT_HEADER::h86b23e12a2a05e14jaa

@alexcrichton
Copy link
Member

How'd you verify this? I tried a few variants myself and it looks like it works.

@ababo
Copy link
Author

ababo commented Aug 3, 2015

It's broken in Nightly release. Try the following code in Playground after choosing 'Asm' and 'Nightly'.

#![crate_type="rlib"]

pub struct Struct {
    pub field: u32,
}

#[link_section = ".my_section"]
pub static VAR: Struct = Struct { field: 1 };

@alexcrichton
Copy link
Member

Aha, looks like I was using an older nightly.

cc @eefriedman, some informal bisecting turns up 8ebf952 as a suspicious commit

@eefriedman
Copy link
Contributor

Yes, that bisection is correct; PR coming up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants