Skip to content

Commit 9b22ad5

Browse files
committed
indicate ppc64 elf abi in e_flags
1 parent 5e0bdaa commit 9b22ad5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,27 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
379379
};
380380
e_flags
381381
}
382+
Architecture::PowerPc64 => {
383+
const EF_PPC64_ABI_UNKNOWN: u32 = 0;
384+
const EF_PPC64_ABI_ELF_V1: u32 = 1;
385+
const EF_PPC64_ABI_ELF_V2: u32 = 2;
386+
387+
if sess.target.options.abi.as_ref().is_empty()
388+
&& sess.target.options.binary_format.to_object() == BinaryFormat::Elf
389+
{
390+
bug!("No ABI specified for this PPC64 ELF target");
391+
}
392+
393+
match sess.target.options.abi.as_ref() {
394+
// If the flags do not correctly indicate the ABI,
395+
// linkers such as ld.lld assume that the ppc64 object files are always ELFv2
396+
// which leads to broken binaries if ELFv1 is used for the object files.
397+
"elfv1" => EF_PPC64_ABI_ELF_V1,
398+
"elfv2" => EF_PPC64_ABI_ELF_V2,
399+
// Fall back
400+
_ => EF_PPC64_ABI_UNKNOWN,
401+
}
402+
}
382403
_ => 0,
383404
}
384405
}

0 commit comments

Comments
 (0)