// FIXME use SHT_X86_64_UNWIND for .eh_frame
let section_id = self.object.add_section(
segment,
- name.clone(),
+ name,
if id == SectionId::EhFrame {
SectionKind::ReadOnlyData
} else {
let init_array_section =
self.object
.add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data);
+ let address_size = self
+ .object
+ .architecture()
+ .address_size()
+ .expect("address_size must be known")
+ .bytes();
self.object.append_section_data(
init_array_section,
&std::iter::repeat(0)
- .take(8 /*FIXME pointer size*/)
+ .take(address_size.into())
.collect::<Vec<u8>>(),
8,
);
init_array_section,
object::write::Relocation {
offset: 0,
- size: 64, // FIXME pointer size
+ size: address_size * 8,
kind: RelocationKind::Absolute,
encoding: RelocationEncoding::Generic,
symbol,
}
pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec<u8> {
- let triple = crate::build_isa(sess, true).triple().clone();
+ let triple = crate::build_isa(sess).triple().clone();
let binary_format = match triple.binary_format {
target_lexicon::BinaryFormat::Elf => object::BinaryFormat::Elf,
pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule {
let mut builder = ObjectBuilder::new(
- crate::build_isa(sess, true),
+ crate::build_isa(sess),
name + ".o",
cranelift_module::default_libcall_names(),
)
.unwrap();
- if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() {
- builder.per_function_section(true);
- }
- let module = ObjectModule::new(builder);
- module
+ // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
+ // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
+ // can easily double the amount of time necessary to perform linking.
+ builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false));
+ ObjectModule::new(builder)
}