symbol_offsets[index].aux_count = 0; match storage_class {
xcoff::C_FILE => {
symbol_offsets[index].aux_count = 1;
symtab_count += 1;
}
xcoff::C_EXT | xcoff::C_WEAKEXT | xcoff::C_HIDEXT => {
symbol_offsets[index].aux_count = 1;
symtab_count += 1;
} // TODO: support auxiliary entry for other types of symbol.
_ => {}
}
} let symtab_offset = offset; let symtab_len = symtab_count * sym_size;
offset += symtab_len;
// Calculate size of strtab. let strtab_offset = offset; letmut strtab_data = Vec::new(); // First 4 bytes of strtab are the length.
strtab.write(4, &mut strtab_data); let strtab_len = strtab_data.len() + 4;
offset += strtab_len;
// Write section headers. for (index, section) inself.sections.iter().enumerate() { letmut sectname = [0; 8];
sectname
.get_mut(..section.name.len())
.ok_or_else(|| {
Error(format!( "section name `{}` is too long",
section.name().unwrap_or(""),
))
})?
.copy_from_slice(§ion.name); let flags = iflet SectionFlags::Xcoff { s_flags } = section.flags {
s_flags
} else { match section.kind {
SectionKind::Text
| SectionKind::ReadOnlyData
| SectionKind::ReadOnlyString
| SectionKind::ReadOnlyDataWithRel => xcoff::STYP_TEXT,
SectionKind::Data => xcoff::STYP_DATA,
SectionKind::UninitializedData => xcoff::STYP_BSS,
SectionKind::Tls => xcoff::STYP_TDATA,
SectionKind::UninitializedTls => xcoff::STYP_TBSS,
SectionKind::OtherString => xcoff::STYP_INFO,
SectionKind::Debug | SectionKind::DebugString => xcoff::STYP_DEBUG,
SectionKind::Other | SectionKind::Metadata => 0,
SectionKind::Note
| SectionKind::Linker
| SectionKind::Common
| SectionKind::Unknown
| SectionKind::TlsVariables
| SectionKind::Elf(_) => { return Err(Error(format!( "unimplemented section `{}` kind {:?}",
section.name().unwrap_or(""),
section.kind
)));
}
}
.into()
}; if is_64 { let section_header = xcoff::SectionHeader64 {
s_name: sectname,
s_paddr: U64::new(BE, section_offsets[index].address), // This field has the same value as the s_paddr field.
s_vaddr: U64::new(BE, section_offsets[index].address),
s_size: U64::new(BE, section.data.len() as u64),
s_scnptr: U64::new(BE, section_offsets[index].data_offset as u64),
s_relptr: U64::new(BE, section_offsets[index].reloc_offset as u64),
s_lnnoptr: U64::new(BE, 0),
s_nreloc: U32::new(BE, section.relocations.len() as u32),
s_nlnno: U32::new(BE, 0),
s_flags: U32::new(BE, flags),
s_reserve: U32::new(BE, 0),
};
buffer.write(§ion_header);
} else { let section_header = xcoff::SectionHeader32 {
s_name: sectname,
s_paddr: U32::new(BE, section_offsets[index].address as u32), // This field has the same value as the s_paddr field.
s_vaddr: U32::new(BE, section_offsets[index].address as u32),
s_size: U32::new(BE, section.data.len() as u32),
s_scnptr: U32::new(BE, section_offsets[index].data_offset as u32),
s_relptr: U32::new(BE, section_offsets[index].reloc_offset as u32),
s_lnnoptr: U32::new(BE, 0), // TODO: If more than 65,534 relocation entries are required, the field // value will be 65535, and an STYP_OVRFLO section header will contain // the actual count of relocation entries in the s_paddr field.
s_nreloc: U16::new(BE, section.relocations.len() as u16),
s_nlnno: U16::new(BE, 0),
s_flags: U32::new(BE, flags),
};
buffer.write(§ion_header);
}
}
// Write section data. for (index, section) inself.sections.iter().enumerate() { let len = section.data.len(); if len != 0 {
write_align(buffer, 4);
debug_assert_eq!(section_offsets[index].data_offset, buffer.len());
buffer.write_bytes(§ion.data);
}
}
// Write relocations. for (index, section) inself.sections.iter().enumerate() { if !section.relocations.is_empty() {
debug_assert_eq!(section_offsets[index].reloc_offset, buffer.len()); for reloc in §ion.relocations { let (r_rtype, r_rsize) = iflet RelocationFlags::Xcoff { r_rtype, r_rsize } = reloc.flags {
(r_rtype, r_rsize)
} else { return Err(Error("invalid relocation flags".into()));
}; if is_64 { let xcoff_rel = xcoff::Rel64 {
r_vaddr: U64::new(BE, reloc.offset),
r_symndx: U32::new(BE, symbol_offsets[reloc.symbol.0].index as u32),
r_rsize,
r_rtype,
};
buffer.write(&xcoff_rel);
} else { let xcoff_rel = xcoff::Rel32 {
r_vaddr: U32::new(BE, reloc.offset as u32),
r_symndx: U32::new(BE, symbol_offsets[reloc.symbol.0].index as u32),
r_rsize,
r_rtype,
};
buffer.write(&xcoff_rel);
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.