diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-07-28 17:18:43 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-08 10:55:36 +0200 |
commit | c1d6637dc786be76721c31fb7712efb4735b8fce (patch) | |
tree | 9f358c20ab0ad176dd78f3457d35ed4e2c0fa9ba /Userland/DevTools/UserspaceEmulator/SoftMMU.h | |
parent | 980f314a0303e0ecbf911d8daf666bb463012524 (diff) | |
download | serenity-c1d6637dc786be76721c31fb7712efb4735b8fce.zip |
UserspaceEmulator: Make symbolication work when .text isn't the first
... segment
This happens with binaries build with Clang or with a custom linker
script. If this is the case, offsets should be calculated not from the
base address of `.text`, but from the first section loaded for the
library.
This commit moves all UserspaceEmulator symbolication into a common
helper function and fixes a FIXME.
Diffstat (limited to 'Userland/DevTools/UserspaceEmulator/SoftMMU.h')
-rw-r--r-- | Userland/DevTools/UserspaceEmulator/SoftMMU.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.h b/Userland/DevTools/UserspaceEmulator/SoftMMU.h index 8767fe2d87..c46e1c8e86 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.h @@ -71,6 +71,16 @@ public: } } + template<typename Type, typename Callback> + void for_each_region_of_type(Callback callback) + { + return for_each_region([callback](auto& region) { + if (!is<Type>(region)) + return IterationDecision::Continue; + return callback(static_cast<Type&>(region)); + }); + } + template<typename Callback> void for_regions_in(X86::LogicalAddress address, size_t size, Callback callback) { |