pub enum ObjectFormat {
Elf,
MachO,
Coff,
Wasm,
}Expand description
The container the compiler writes.
One per OS, with freestanding taking its format from the architecture. rucc writes all four itself rather than handing text to an assembler, which is why this is a first class field: every one of them is a different section model, a different relocation table and a different symbol table.
Variants§
Elf
ELF. Linux, the BSDs, illumos, and freestanding on every architecture but wasm.
MachO
Mach-O. Darwin, and the format with a version treadmill: chained fixups and
__init_offsets are recent and are not optional on current systems.
Coff
COFF, in its PE flavour. Windows, both environments, with unwind information in
.pdata and .xdata rather than in a DWARF section.
Wasm
The WebAssembly object format. A different shape from the other three, and
spec/cross-compile/05-architectures.md section 5.9 treats reaching it as a second back end.
Implementations§
Source§impl ObjectFormat
impl ObjectFormat
Sourcepub const fn object_extension(self) -> &'static str
pub const fn object_extension(self) -> &'static str
The suffix an object file gets on this format.
Sourcepub const fn archive_extension(self) -> &'static str
pub const fn archive_extension(self) -> &'static str
The suffix a static archive gets.
Sourcepub const fn leading_underscore(self, data_model: DataModel) -> bool
pub const fn leading_underscore(self, data_model: DataModel) -> bool
Whether symbols are prefixed with an underscore.
True on Mach-O and on 32-bit COFF, false on ELF and 64-bit COFF. Getting this wrong produces a link error naming a symbol that is visibly present in the object, which is one of the more confusing ways to spend an afternoon.
Trait Implementations§
Source§impl Clone for ObjectFormat
impl Clone for ObjectFormat
Source§fn clone(&self) -> ObjectFormat
fn clone(&self) -> ObjectFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more