-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow marking data objects as used for the linker #11206
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
Conversation
cranelift/object/src/backend.rs
Outdated
_ => unreachable!(), | ||
} | ||
} | ||
object::BinaryFormat::Coff => {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I think this is missing N_WEAK_REF
/N_WEAK_DEF
for weak symbols.
Fixes #10758