Allow marking data objects as used for the linker#11206
Allow marking data objects as used for the linker#11206abrown merged 1 commit intobytecodealliance:mainfrom
Conversation
cranelift/object/src/backend.rs
Outdated
| _ => unreachable!(), | ||
| } | ||
| } | ||
| object::BinaryFormat::Coff => {}, |
There was a problem hiding this comment.
I couldn't find what flag is necessary for Windows (if any).
|
Also could this get a backport to the branch for the next Cranelift release. rust-lang/rust#140525 has removed a workaround for |
abrown
left a comment
There was a problem hiding this comment.
I'm no expert here but this seems reasonable.
| match &mut section.flags { | ||
| SectionFlags::None => { | ||
| section.flags = SectionFlags::Elf { | ||
| sh_flags: object::elf::SHF_GNU_RETAIN.into(), |
There was a problem hiding this comment.
This should have also included elf::SHF_ALLOC | elf::SHF_WRITE (or elf::SHF_ALLOC only when the data object is neither writable nor contains relocations).
| let symbol = self.object.symbol_mut(symbol); | ||
| assert!(matches!(symbol.flags, SymbolFlags::None)); | ||
| symbol.flags = SymbolFlags::MachO { | ||
| n_desc: object::macho::N_NO_DEAD_STRIP, |
There was a problem hiding this comment.
And I think this is missing N_WEAK_REF/N_WEAK_DEF for weak symbols.
Fixes #10758