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 <jwkozac...@gmail.com>
---
 core/elf.cc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/core/elf.cc b/core/elf.cc
index 94e14b07..3cf1f873 100644
--- a/core/elf.cc
+++ b/core/elf.cc
@@ -91,8 +91,6 @@ void* symbol_module::relocated_addr() const
     }
     switch (symbol_type(*symbol)) {
     case STT_NOTYPE:
-        return reinterpret_cast<void*>(symbol->st_value);
-        break;
     case STT_OBJECT:
     case STT_FUNC:
         return base + symbol->st_value;
-- 
2.30.2

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210429161402.797575-1-jwkozaczuk%40gmail.com.

Reply via email to