1
Fork 0

Auto merge of #106619 - agausmann:avr-object-file, r=nagisa

Fix unset e_flags in ELF files generated for AVR targets

Closes #106576

~~Sort-of blocked by gimli-rs/object#500~~ (merged)

I'm not sure whether the list of AVR CPU names is okay here. Maybe it could be moved out-of-line to improve the readability of the function.
This commit is contained in:
bors 2023-06-30 08:55:56 +00:00
commit af9df2fd91
5 changed files with 350 additions and 1 deletions

View file

@ -20,7 +20,7 @@ use rustc_metadata::EncodedMetadata;
use rustc_session::cstore::MetadataLoader;
use rustc_session::Session;
use rustc_target::abi::Endian;
use rustc_target::spec::{RelocModel, Target};
use rustc_target::spec::{ef_avr_arch, RelocModel, Target};
/// The default metadata loader. This is used by cg_llvm and cg_clif.
///
@ -287,6 +287,11 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
// Source: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version
elf::EF_LARCH_OBJABI_V1 | elf::EF_LARCH_ABI_DOUBLE_FLOAT
}
Architecture::Avr => {
// Resolve the ISA revision and set
// the appropriate EF_AVR_ARCH flag.
ef_avr_arch(&sess.target.options.cpu)
}
_ => 0,
};
// adapted from LLVM's `MCELFObjectTargetWriter::getOSABI`