Ignore relocations in the vdso.
glibc and musl both explicitly ignore relocations in the vdso. There
shouldn't be any, but the Ubuntu 24.04 risc-v kernel accidentally
contained relocations, which meant that bionic binaries couldn't start
where glibc/musl ones could.
This shouldn't happen again (because there's now a check as part of the
kernel build[1]), but we might as well behave like the other two libcs that
deal with Linux?
Separately, there shouldn't be any ELF constructors in the vdso, so I've
removed that line too.
In addition, we were giving the appearance of error handling here by
only setting the global vdso at the end of the function, but we were
doing that regardless of whether prelinking and linking had actually
succeeded. So replace that with explicit checks and a call to the usual
shouty "CANNOT LINK EXECUTABLE" panic function.
[1] https://lore.kernel.org/lkml/7fac15fb-83e0-4711-91a0-db0cb616c2c9@ghiti.fr/T/
Change-Id: I69ca6526e92ac1be0d52ce0d40b2f1091decd6da
diff --git a/linker/linker.cpp b/linker/linker.cpp
index e13d37d..2eb3cae 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3370,7 +3370,7 @@
}
#endif
- if (!relocate(lookup_list)) {
+ if (this != solist_get_vdso() && !relocate(lookup_list)) {
return false;
}