From f66156b3d1f46c0491dfba04cff4bb75c9d72adf Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Tue, 14 Jul 2026 16:51:43 +1000 Subject: [PATCH] feat(ld.so): specify dynamic list Signed-off-by: Anhad Singh --- Makefile | 8 ++++++-- dynlst.txt | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 dynlst.txt diff --git a/Makefile b/Makefile index c7c2967a5b..9752c14058 100644 --- a/Makefile +++ b/Makefile @@ -147,8 +147,12 @@ $(BUILD)/$(PROFILE)/libc.so: $(BUILD)/$(PROFILE)/libc.a -o $@ $(BUILD)/$(PROFILE)/ld.so: $(BUILD)/$(PROFILE)/ld_so.o $(BUILD)/$(PROFILE)/libc.a - # TODO: merge ld.so with libc.so: --dynamic-list=dynamic-list-file - $(LD) --shared -Bsymbolic --no-relax -T ld_so/ld_script/$(TARGET).ld --gc-sections $^ -o $@ + # Specifying a dynamic list makes all non-local `STV_DEFAULT` + # definitions non-preemptible, except for the symbols listed in + # `dynlst.txt`. So, the symbols defined in `dynlst.txt` may be + # interposed by other definitions at runtime (either from the + # executable or some shared library). + $(LD) --shared --whole-archive --dynamic-list=dynlst.txt $^ -o $@ $(BUILD)/$(PROFILE)/libc.a: $(BUILD)/$(PROFILE)/librelibc.a $(BUILD)/openlibm/libopenlibm.a echo "create $@" > "$@.mri" diff --git a/dynlst.txt b/dynlst.txt new file mode 100644 index 0000000000..464ef44fa9 --- /dev/null +++ b/dynlst.txt @@ -0,0 +1,5 @@ +{ +stdin; +stdout; +stderr; +};