From 3aa68a3784191c7b76e22cf42c2c901f7485baf5 Mon Sep 17 00:00:00 2001 From: David Gow Date: Mon, 12 Sep 2022 19:44:33 +0800 Subject: [PATCH] rust: Use 'pie' relocation mode under UML UML expects a position independent executable for some reason, so tell rustc to generate pie objects. Otherwise we get a bunch of relocations we can't deal with in libcore. Signed-off-by: David Gow --- Makefile | 1 - scripts/generate_rust_target.rs | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a105cb893b4ca0..e4b54fb040f24b 100644 --- a/Makefile +++ b/Makefile @@ -567,7 +567,6 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) \ -Cpanic=abort -Cembed-bitcode=n -Clto=n \ -Cforce-unwind-tables=n -Ccodegen-units=1 \ -Csymbol-mangling-version=v0 \ - -Crelocation-model=static \ -Zfunction-sections=n \ -Dclippy::float_arithmetic diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs index e36211e6161117..11a4ab1f502060 100644 --- a/scripts/generate_rust_target.rs +++ b/scripts/generate_rust_target.rs @@ -228,5 +228,11 @@ fn main() { ts.push("target-endian", "big"); } + if cfg.has("UML") { + ts.push("relocation-model", "pie"); + } else { + ts.push("relocation-model", "static"); + } + println!("{}", ts); }