From ad182bcb4bfe17f618c0031410554cb789386ddb Mon Sep 17 00:00:00 2001 From: hanzhijian Date: Wed, 20 May 2026 19:49:18 +0800 Subject: [PATCH] sim: resolve host symbols eagerly on Linux Resolve PLT entries at load time on Linux hosts so early host calls do not enter the lazy binder with simulated interrupts masked. On Ubuntu 20 with GCC 9, the sim:nsh binary linked successfully after the -no-pie fix but crashed very early at runtime inside _dl_fixup / _dl_runtime_resolve_xsavec when up_irq_save() triggered a first-time PLT resolution. Setting LD_BIND_NOW=1 avoided the crash and allowed NSH to start, which showed lazy binding was the trigger. Signed-off-by: hanzhijian --- boards/sim/sim/sim/scripts/Make.defs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 42d78e826b0..0a65fb44e25 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -340,6 +340,10 @@ else ifeq ($(CONFIG_HOST_MACOS)$(CONFIG_HOST_ARM64),) endif ifeq ($(CONFIG_HOST_LINUX),y) + # Resolve PLT entries at load time so early host calls made with + # simulated interrupts masked do not fault inside the lazy binder. + LDFLAGS += -Wl,-z,now + define POSTBUILD $(Q)echo "Pac SIM with dynamic libs.."; @ rm -rf sim-pac;