Skip to content

LTO ignores linker script KEEP directives #9844

@leecannon

Description

@leecannon

A linker script with a section containing a KEEP directive and with a symbol exported into that section is not present in the binary if LTO is enabled.

in linker script:

.stivale2hdr ALIGN(4K) : {
    KEEP(*(.stivale2hdr))
} :rodata

in root zig file:

pub export const header linksection(".stivale2hdr") = // struct initalization here

If want_lto is set to false or null then the binary will contain the stivale2hdr section

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorupstreamAn issue with a third party project that Zig uses.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions