|
| 1 | +From 7ae19a08467254f0b3d7a513ef82651b283f38a9 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Tim Besard <tim.besard@gmail.com> |
| 3 | +Date: Wed, 27 Sep 2023 12:51:59 +0000 |
| 4 | +Subject: [PATCH] Revert "Fix unwinding of pre-linked libraries" |
| 5 | + |
| 6 | +This reverts commit a4014f33775321b4106a1134b89020a7774902dd, |
| 7 | +which regresses unwinding on FreeBSD (JuliaLang/julia#51467). |
| 8 | +--- |
| 9 | + include/dwarf.h | 2 -- |
| 10 | + include/libunwind-dynamic.h | 1 - |
| 11 | + src/dwarf/Gfind_proc_info-lsb.c | 42 +++++++-------------------------- |
| 12 | + src/dwarf/Gfind_unwind_table.c | 1 - |
| 13 | + 4 files changed, 8 insertions(+), 38 deletions(-) |
| 14 | + |
| 15 | +diff --git a/include/dwarf.h b/include/dwarf.h |
| 16 | +index dd9014b7..312166cd 100644 |
| 17 | +--- a/include/dwarf.h |
| 18 | ++++ b/include/dwarf.h |
| 19 | +@@ -371,8 +371,6 @@ struct unw_debug_frame_list |
| 20 | + /* The start (inclusive) and end (exclusive) of the described region. */ |
| 21 | + unw_word_t start; |
| 22 | + unw_word_t end; |
| 23 | +- /* ELF load offset */ |
| 24 | +- unw_word_t load_offset; |
| 25 | + /* The debug frame itself. */ |
| 26 | + char *debug_frame; |
| 27 | + size_t debug_frame_size; |
| 28 | +diff --git a/include/libunwind-dynamic.h b/include/libunwind-dynamic.h |
| 29 | +index a26f2c99..c902ccd9 100644 |
| 30 | +--- a/include/libunwind-dynamic.h |
| 31 | ++++ b/include/libunwind-dynamic.h |
| 32 | +@@ -141,7 +141,6 @@ typedef struct unw_dyn_info |
| 33 | + unw_word_t gp; /* global-pointer in effect for this entry */ |
| 34 | + int32_t format; /* real type: unw_dyn_info_format_t */ |
| 35 | + int32_t pad; |
| 36 | +- unw_word_t load_offset; /* ELF load offset */ |
| 37 | + union |
| 38 | + { |
| 39 | + unw_dyn_proc_info_t pi; |
| 40 | +diff --git a/src/dwarf/Gfind_proc_info-lsb.c b/src/dwarf/Gfind_proc_info-lsb.c |
| 41 | +index 8ead48f0..154e9b5a 100644 |
| 42 | +--- a/src/dwarf/Gfind_proc_info-lsb.c |
| 43 | ++++ b/src/dwarf/Gfind_proc_info-lsb.c |
| 44 | +@@ -108,17 +108,13 @@ linear_search (unw_addr_space_t as, unw_word_t ip, |
| 45 | + |
| 46 | + static int |
| 47 | + load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local, |
| 48 | +- unw_word_t segbase, unw_word_t *load_offset) |
| 49 | ++ unw_word_t segbase) |
| 50 | + { |
| 51 | + struct elf_image ei; |
| 52 | +- Elf_W (Ehdr) *ehdr; |
| 53 | +- Elf_W (Phdr) *phdr; |
| 54 | + Elf_W (Shdr) *shdr; |
| 55 | +- int i; |
| 56 | + int ret; |
| 57 | + |
| 58 | + ei.image = NULL; |
| 59 | +- *load_offset = 0; |
| 60 | + |
| 61 | + ret = elf_w (load_debuglink) (file, &ei, is_local); |
| 62 | + if (ret != 0) |
| 63 | +@@ -193,20 +189,6 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local, |
| 64 | + #if defined(SHF_COMPRESSED) |
| 65 | + } |
| 66 | + #endif |
| 67 | +- |
| 68 | +- ehdr = ei.image; |
| 69 | +- phdr = (Elf_W (Phdr) *) ((char *) ei.image + ehdr->e_phoff); |
| 70 | +- |
| 71 | +- for (i = 0; i < ehdr->e_phnum; ++i) |
| 72 | +- if (phdr[i].p_type == PT_LOAD) |
| 73 | +- { |
| 74 | +- *load_offset = segbase - phdr[i].p_vaddr; |
| 75 | +- |
| 76 | +- Debug (4, "%s load offset is 0x%zx\n", file, *load_offset); |
| 77 | +- |
| 78 | +- break; |
| 79 | +- } |
| 80 | +- |
| 81 | + munmap(ei.image, ei.size); |
| 82 | + return 0; |
| 83 | + } |
| 84 | +@@ -259,7 +241,6 @@ locate_debug_info (unw_addr_space_t as, unw_word_t addr, unw_word_t segbase, |
| 85 | + int err; |
| 86 | + char *buf; |
| 87 | + size_t bufsize; |
| 88 | +- unw_word_t load_offset; |
| 89 | + |
| 90 | + /* First, see if we loaded this frame already. */ |
| 91 | + |
| 92 | +@@ -287,7 +268,7 @@ locate_debug_info (unw_addr_space_t as, unw_word_t addr, unw_word_t segbase, |
| 93 | + name = (char*) dlname; |
| 94 | + |
| 95 | + err = load_debug_frame (name, &buf, &bufsize, as == unw_local_addr_space, |
| 96 | +- segbase, &load_offset); |
| 97 | ++ segbase); |
| 98 | + |
| 99 | + if (!err) |
| 100 | + { |
| 101 | +@@ -300,7 +281,6 @@ locate_debug_info (unw_addr_space_t as, unw_word_t addr, unw_word_t segbase, |
| 102 | + |
| 103 | + fdesc->start = start; |
| 104 | + fdesc->end = end; |
| 105 | +- fdesc->load_offset = load_offset; |
| 106 | + fdesc->debug_frame = buf; |
| 107 | + fdesc->debug_frame_size = bufsize; |
| 108 | + fdesc->index = NULL; |
| 109 | +@@ -497,7 +477,6 @@ dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug, unw_word_t ip, |
| 110 | + di->format = UNW_INFO_FORMAT_TABLE; |
| 111 | + di->start_ip = fdesc->start; |
| 112 | + di->end_ip = fdesc->end; |
| 113 | +- di->load_offset = fdesc->load_offset; |
| 114 | + di->u.ti.name_ptr = (unw_word_t) (uintptr_t) obj_name; |
| 115 | + di->u.ti.table_data = (unw_word_t *) fdesc; |
| 116 | + di->u.ti.table_len = sizeof (*fdesc) / sizeof (unw_word_t); |
| 117 | +@@ -960,14 +939,12 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, |
| 118 | + ip_base = segbase; |
| 119 | + } |
| 120 | + |
| 121 | +- Debug (6, "lookup IP 0x%lx\n", (long) (ip - ip_base - di->load_offset)); |
| 122 | +- |
| 123 | + #ifndef UNW_REMOTE_ONLY |
| 124 | + if (as == unw_local_addr_space) |
| 125 | + { |
| 126 | +- e = lookup (table, table_len, ip - ip_base - di->load_offset); |
| 127 | ++ e = lookup (table, table_len, ip - ip_base); |
| 128 | + if (e && &e[1] < &table[table_len / sizeof (unw_word_t)]) |
| 129 | +- last_ip = e[1].start_ip_offset + ip_base + di->load_offset; |
| 130 | ++ last_ip = e[1].start_ip_offset + ip_base; |
| 131 | + else |
| 132 | + last_ip = di->end_ip; |
| 133 | + } |
| 134 | +@@ -975,7 +952,7 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, |
| 135 | + #endif |
| 136 | + { |
| 137 | + #ifndef UNW_LOCAL_ONLY |
| 138 | +- int32_t last_ip_offset = di->end_ip - ip_base - di->load_offset; |
| 139 | ++ int32_t last_ip_offset = di->end_ip - ip_base; |
| 140 | + segbase = di->u.rti.segbase; |
| 141 | + if ((ret = remote_lookup (as, (uintptr_t) table, table_len, |
| 142 | + ip - ip_base, &ent, &last_ip_offset, arg)) < 0) |
| 143 | +@@ -983,7 +960,7 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, |
| 144 | + if (ret) |
| 145 | + { |
| 146 | + e = &ent; |
| 147 | +- last_ip = last_ip_offset + ip_base + di->load_offset; |
| 148 | ++ last_ip = last_ip_offset + ip_base; |
| 149 | + } |
| 150 | + else |
| 151 | + e = NULL; /* no info found */ |
| 152 | +@@ -997,8 +974,8 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, |
| 153 | + unwind info. */ |
| 154 | + return -UNW_ENOINFO; |
| 155 | + } |
| 156 | +- Debug (15, "ip=0x%lx, load_offset=0x%lx, start_ip=0x%lx\n", |
| 157 | +- (long) ip, (long) di->load_offset, (long) (e->start_ip_offset)); |
| 158 | ++ Debug (15, "ip=0x%lx, start_ip=0x%lx\n", |
| 159 | ++ (long) ip, (long) (e->start_ip_offset)); |
| 160 | + if (debug_frame_base) |
| 161 | + fde_addr = e->fde_offset + debug_frame_base; |
| 162 | + else |
| 163 | +@@ -1022,9 +999,6 @@ dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, |
| 164 | + pi->flags = UNW_PI_FLAG_DEBUG_FRAME; |
| 165 | + } |
| 166 | + |
| 167 | +- pi->start_ip += di->load_offset; |
| 168 | +- pi->end_ip += di->load_offset; |
| 169 | +- |
| 170 | + #if defined(NEED_LAST_IP) |
| 171 | + pi->last_ip = last_ip; |
| 172 | + #else |
| 173 | +diff --git a/src/dwarf/Gfind_unwind_table.c b/src/dwarf/Gfind_unwind_table.c |
| 174 | +index fb20fea0..62feb26c 100644 |
| 175 | +--- a/src/dwarf/Gfind_unwind_table.c |
| 176 | ++++ b/src/dwarf/Gfind_unwind_table.c |
| 177 | +@@ -193,7 +193,6 @@ dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as, |
| 178 | + |
| 179 | + edi->di_cache.start_ip = start_ip; |
| 180 | + edi->di_cache.end_ip = end_ip; |
| 181 | +- edi->di_cache.load_offset = 0; |
| 182 | + edi->di_cache.format = UNW_INFO_FORMAT_REMOTE_TABLE; |
| 183 | + edi->di_cache.u.rti.name_ptr = 0; |
| 184 | + /* two 32-bit values (ip_offset/fde_offset) per table-entry: */ |
| 185 | +-- |
| 186 | +2.41.0 |
| 187 | + |
0 commit comments