[PATCH] D86748: [libunwind] Bare-metal DWARF: set dso_base to 0
Ryan Prichard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 16:22:29 PDT 2020
rprichard created this revision.
rprichard added reviewers: compnerd, mstorsjo, whitequark.
Herald added subscribers: libcxx-commits, llvm-commits, aprantl.
Herald added projects: LLVM, libunwind.
Herald added a reviewer: libunwind.
rprichard requested review of this revision.
DwarfFDECache::findFDE normally uses mh==0 as a flag indicating that it
should search the entire cache, including dynamically-registered FDEs.
Replace this sentinel value with a bool parameter.
Fixes PR47335.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86748
Files:
libunwind/src/AddressSpace.hpp
libunwind/src/UnwindCursor.hpp
Index: libunwind/src/UnwindCursor.hpp
===================================================================
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -81,7 +81,7 @@
class _LIBUNWIND_HIDDEN DwarfFDECache {
typedef typename A::pint_t pint_t;
public:
- static pint_t findFDE(pint_t mh, pint_t pc);
+ static pint_t findFDE(pint_t mh, bool ignore_mh, pint_t pc);
static void add(pint_t mh, pint_t ip_start, pint_t ip_end, pint_t fde);
static void removeAllIn(pint_t mh);
static void iterateCacheEntries(void (*func)(unw_word_t ip_start,
@@ -134,11 +134,12 @@
#endif
template <typename A>
-typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) {
+typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, bool ignore_mh,
+ pint_t pc) {
pint_t result = 0;
_LIBUNWIND_LOG_IF_FALSE(_lock.lock_shared());
for (entry *p = _buffer; p < _bufferUsed; ++p) {
- if ((mh == p->mh) || (mh == 0)) {
+ if ((mh == p->mh) || ignore_mh) {
if ((p->ip_start <= pc) && (pc < p->ip_end)) {
result = p->fde;
break;
@@ -1529,7 +1530,7 @@
#endif
if (!foundFDE) {
// otherwise, search cache of previously found FDEs.
- pint_t cachedFDE = DwarfFDECache<A>::findFDE(sects.dso_base, pc);
+ pint_t cachedFDE = DwarfFDECache<A>::findFDE(sects.dso_base, false, pc);
if (cachedFDE != 0) {
foundFDE =
CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
@@ -1945,7 +1946,7 @@
#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
// There is no static unwind info for this pc. Look to see if an FDE was
// dynamically registered for it.
- pint_t cachedFDE = DwarfFDECache<A>::findFDE(0, pc);
+ pint_t cachedFDE = DwarfFDECache<A>::findFDE(0, true, pc);
if (cachedFDE != 0) {
typename CFI_Parser<A>::FDE_Info fdeInfo;
typename CFI_Parser<A>::CIE_Info cieInfo;
Index: libunwind/src/AddressSpace.hpp
===================================================================
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -535,6 +535,7 @@
return true;
}
#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL)
+ info.dso_base = 0;
// Bare metal is statically linked, so no need to ask the dynamic loader
info.dwarf_section_length = (uintptr_t)(&__eh_frame_end - &__eh_frame_start);
info.dwarf_section = (uintptr_t)(&__eh_frame_start);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86748.288480.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200827/15589820/attachment.bin>
More information about the llvm-commits
mailing list