Skip to content

Commit 7905eff

Browse files
committed
Auto merge of rust-lang#112550 - loongarch-rs:fix-eflags, r=cjgillot
loongarch: Fix ELF header flags This patch changes the ELF header flags so that the ABI matches the floating-point features. It also updates the link to the new official documentation.
2 parents e5bb341 + aa8e864 commit 7905eff

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,19 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
284284
e_flags
285285
}
286286
Architecture::LoongArch64 => {
287-
// Source: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version
288-
elf::EF_LARCH_OBJABI_V1 | elf::EF_LARCH_ABI_DOUBLE_FLOAT
287+
// Source: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#e_flags-identifies-abi-type-and-version
288+
let mut e_flags: u32 = elf::EF_LARCH_OBJABI_V1;
289+
let features = &sess.target.options.features;
290+
291+
// Select the appropriate floating-point ABI
292+
if features.contains("+d") {
293+
e_flags |= elf::EF_LARCH_ABI_DOUBLE_FLOAT;
294+
} else if features.contains("+f") {
295+
e_flags |= elf::EF_LARCH_ABI_SINGLE_FLOAT;
296+
} else {
297+
e_flags |= elf::EF_LARCH_ABI_SOFT_FLOAT;
298+
}
299+
e_flags
289300
}
290301
Architecture::Avr => {
291302
// Resolve the ISA revision and set

0 commit comments

Comments
 (0)