mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
ldso: fix page fault at IP 0 with GCC 12 on RISC-V
Eliminate the creation of 'Genode::String's before the linker has been self relocated, because 'Genode::String's will call 'Genode::strlen' on construction from C-Strings, which has now become a GOT relative call, while the GOT contains only zeros before relocation -> page fault at IP 0. fixes #4867 related to #4827
This commit is contained in:
parent
d35e6f1aa2
commit
d59a2b4b38
@ -162,10 +162,11 @@ class Linker::Object : private Fifo<Object>::Element,
|
||||
|
||||
public:
|
||||
|
||||
void init(Name const &name, Elf::Addr reloc_base)
|
||||
void init(char const *name, Elf::Addr reloc_base)
|
||||
{
|
||||
_name = name;
|
||||
_reloc_base = reloc_base;
|
||||
|
||||
if (name) _name = name;
|
||||
}
|
||||
|
||||
void init(Name const &name, File const &file)
|
||||
|
@ -107,7 +107,7 @@ class Linker::Elf_object : public Object, private Fifo<Elf_object>::Element
|
||||
Constructible<Elf_file> _elf_file { };
|
||||
|
||||
|
||||
bool _object_init(Object::Name const &name, Elf::Addr reloc_base)
|
||||
bool _object_init(char const *name, Elf::Addr reloc_base)
|
||||
{
|
||||
Object::init(name, reloc_base);
|
||||
return true;
|
||||
@ -126,7 +126,7 @@ class Linker::Elf_object : public Object, private Fifo<Elf_object>::Element
|
||||
|
||||
public:
|
||||
|
||||
Elf_object(Dependency const &dep, Object::Name const &name,
|
||||
Elf_object(Dependency const &dep, char const *name,
|
||||
Elf::Addr reloc_base) SELF_RELOC
|
||||
:
|
||||
_elf_object_initialized(_object_init(name, reloc_base)),
|
||||
@ -261,9 +261,9 @@ class Linker::Elf_object : public Object, private Fifo<Elf_object>::Element
|
||||
*/
|
||||
struct Linker::Ld : private Dependency, Elf_object
|
||||
{
|
||||
Ld() SELF_RELOC :
|
||||
Ld(bool use_name = true) SELF_RELOC :
|
||||
Dependency(*this, nullptr),
|
||||
Elf_object(*this, linker_name(), relocation_address())
|
||||
Elf_object(*this, use_name ? linker_name() : nullptr, relocation_address())
|
||||
{ }
|
||||
|
||||
void setup_link_map()
|
||||
@ -656,7 +656,7 @@ extern "C" void init_rtld()
|
||||
* type relocation might produce a wrong vtable pointer (at least on ARM), do
|
||||
* not call any virtual funtions of this object.
|
||||
*/
|
||||
Ld linker_on_stack;
|
||||
Ld linker_on_stack { false };
|
||||
linker_on_stack.relocate(BIND_LAZY);
|
||||
|
||||
/* init cxa guard mechanism before any local static variables are used */
|
||||
|
Loading…
Reference in New Issue
Block a user