[PATCH] elf: capture address of PT_GNU_EH_FRAME

10 views
Skip to first unread message

Waldemar Kozaczuk

unread,
May 11, 2022, 10:10:07 AM5/11/22
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
core/elf.cc | 5 ++++-
include/osv/elf.hh | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/elf.cc b/core/elf.cc
index 5170bf53..c96a45ec 100644
--- a/core/elf.cc
+++ b/core/elf.cc
@@ -124,6 +124,7 @@ object::object(program& prog, std::string pathname)
, _module_index(_prog.register_dtv(this))
, _is_executable(false)
, _init_called(false)
+ , _eh_frame(0)
, _visibility_thread(nullptr)
, _visibility_level(VisibilityLevel::Public)
{
@@ -517,10 +518,12 @@ void object::process_headers()
case PT_PHDR:
case PT_GNU_STACK:
case PT_GNU_RELRO:
- case PT_GNU_EH_FRAME:
case PT_PAX_FLAGS:
case PT_GNU_PROPERTY:
break;
+ case PT_GNU_EH_FRAME:
+ _eh_frame = _base + phdr.p_vaddr;
+ break;
case PT_TLS:
_tls_segment = _base + phdr.p_vaddr;
_tls_init_size = phdr.p_filesz;
diff --git a/include/osv/elf.hh b/include/osv/elf.hh
index afc9c9a5..31702bf8 100644
--- a/include/osv/elf.hh
+++ b/include/osv/elf.hh
@@ -383,6 +383,7 @@ public:
ulong get_tls_size();
ulong get_aligned_tls_size();
void copy_local_tls(void* to_addr);
+ void* eh_frame_addr() { return _eh_frame; }
protected:
virtual void load_segment(const Elf64_Phdr& segment) = 0;
virtual void unload_segment(const Elf64_Phdr& segment) = 0;
@@ -436,6 +437,7 @@ protected:
bool _is_executable;
bool is_core();
bool _init_called;
+ void* _eh_frame;

std::unordered_map<std::string,void*> _cached_symbols;

--
2.34.1

Commit Bot

unread,
May 13, 2022, 5:21:15 PM5/13/22
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

elf: capture address of PT_GNU_EH_FRAME

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/core/elf.cc b/core/elf.cc
--- a/core/elf.cc
+++ b/core/elf.cc
@@ -124,6 +124,7 @@ object::object(program& prog, std::string pathname)
, _module_index(_prog.register_dtv(this))
, _is_executable(false)
, _init_called(false)
+ , _eh_frame(0)
, _visibility_thread(nullptr)
, _visibility_level(VisibilityLevel::Public)
{
@@ -517,10 +518,12 @@ void object::process_headers()
case PT_PHDR:
case PT_GNU_STACK:
case PT_GNU_RELRO:
- case PT_GNU_EH_FRAME:
case PT_PAX_FLAGS:
case PT_GNU_PROPERTY:
break;
+ case PT_GNU_EH_FRAME:
+ _eh_frame = _base + phdr.p_vaddr;
+ break;
case PT_TLS:
_tls_segment = _base + phdr.p_vaddr;
_tls_init_size = phdr.p_filesz;
diff --git a/include/osv/elf.hh b/include/osv/elf.hh
Reply all
Reply to author
Forward
0 new messages