Some ELF files define global variables symbols with STT_NOTYPE
like in this example:
13030: 000000000243b390 0 NOTYPE GLOBAL DEFAULT 13 v8_Default_embedded_blob_size_
13136: 0000000002d09db8 0 NOTYPE GLOBAL DEFAULT 24 v8_Default_embedded_blob_
Currently OSv dynamic linker will resolve such symbols at the relative
offset as specified by st_value and cause page fault. This patch fixes
this logic by correctly adding the base of the ELF to the st_value.
This patch effectively makes it possibly to run latest Node.JS 12 and 14
on OSv.
Signed-off-by: Waldemar Kozaczuk <
jwkoz...@gmail.com>
---
core/elf.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/elf.cc b/core/elf.cc
index 94e14b07..7c63bbfc 100644
--- a/core/elf.cc
+++ b/core/elf.cc
@@ -91,7 +91,7 @@ void* symbol_module::relocated_addr() const
}
switch (symbol_type(*symbol)) {
case STT_NOTYPE:
- return reinterpret_cast<void*>(symbol->st_value);
+ return reinterpret_cast<void*>(base + symbol->st_value);
break;
case STT_OBJECT:
case STT_FUNC:
--
2.30.2