diff --git a/repos/base/src/lib/ldso/include/dynamic.h b/repos/base/src/lib/ldso/include/dynamic.h index bc96fb51c3..275bf1bcaa 100644 --- a/repos/base/src/lib/ldso/include/dynamic.h +++ b/repos/base/src/lib/ldso/include/dynamic.h @@ -144,7 +144,7 @@ class Linker::Dynamic _d->un.ptr = (Elf::Addr)Debug::d(); } - void _init() + void _init() SELF_RELOC { for (Elf::Dyn const *d = &_dynamic; d->tag != DT_NULL; d++) { switch (d->tag) { @@ -308,7 +308,7 @@ class Linker::Dynamic fn(n->path(_strtab)); } - void relocate(Bind bind) + void relocate(Bind bind) SELF_RELOC { plt_setup(); diff --git a/repos/base/src/lib/ldso/include/linker.h b/repos/base/src/lib/ldso/include/linker.h index 31d7971159..c36e756946 100644 --- a/repos/base/src/lib/ldso/include/linker.h +++ b/repos/base/src/lib/ldso/include/linker.h @@ -20,6 +20,13 @@ #include #include +/* + * Mark functions that are used during the linkers self-relocation phase as + * always inline. Some platforms (riscv) perform function calls through the + * GOT that is not initialized (zero) at this state. + */ +#define SELF_RELOC __attribute__((always_inline)) + /** * Forward declartions and helpers */ diff --git a/repos/base/src/lib/ldso/main.cc b/repos/base/src/lib/ldso/main.cc index f9115ada82..d6fb5fd323 100644 --- a/repos/base/src/lib/ldso/main.cc +++ b/repos/base/src/lib/ldso/main.cc @@ -197,7 +197,7 @@ class Linker::Elf_object : public Object, public Fifo::Element void update_dependency(Dependency const &dep) { _dyn.dep(dep); } - void relocate(Bind bind) override + void relocate(Bind bind) override SELF_RELOC { if (!_relocated) _dyn.relocate(bind);