Skip to content

Instantly share code, notes, and snippets.

@zhuizhuhaomeng
Last active July 7, 2023 00:08
Show Gist options
  • Save zhuizhuhaomeng/f7d9d45c956346091c48313bccdfdbfd to your computer and use it in GitHub Desktop.
Save zhuizhuhaomeng/f7d9d45c956346091c48313bccdfdbfd to your computer and use it in GitHub Desktop.
commit b322f8820f0a965bd95315d73bfecd377fe82231
Author: lijunlong <lijunlong@openresty.com>
Date: Thu Jul 6 21:39:30 2023 +0800
bugfix: unwind failed because did not get unwind data from the .zdebug_frame section.
diff --git a/translate.cxx b/translate.cxx
index 4115650e3..568b50c3c 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -7061,9 +7061,13 @@ static void get_unwind_data (Dwfl_Module *m,
scn = NULL;
while ((scn = elf_nextscn(elf, scn)))
{
+ const char *sh_name;
shdr = gelf_getshdr(scn, &shdr_mem);
- if (strcmp(elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name),
- ".debug_frame") == 0)
+ sh_name = elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name);
+ // decompression is done via dwarf_begin_elf / global_read / check_section
+ // / elf_compress_gnu / __libelf_decompress in libelf/elf_compress_gnu.c
+ if (strcmp(sh_name, ".debug_frame") == 0
+ || strcmp(sh_name, ".zdebug_frame") == 0)
{
data = elf_rawdata(scn, NULL);
*debug_frame = data->d_buf;
@@ -7230,9 +7234,13 @@ static void find_debug_frame_offset (Dwfl_Module *m,
while ((scn = elf_nextscn(elf, scn)))
{
+ const char *sh_name;
shdr = gelf_getshdr(scn, &shdr_mem);
- if (strcmp(elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name),
- ".debug_frame") == 0)
+ sh_name = elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name);
+ // decompression is done via dwarf_begin_elf / global_read / check_section
+ // / elf_compress_gnu / __libelf_decompress in libelf/elf_compress_gnu.c
+ if (strcmp(sh_name, ".debug_frame") == 0
+ || strcmp(sh_name, ".zdebug_frame") == 0)
{
data = elf_rawdata(scn, NULL);
break;
@@ -7372,9 +7380,13 @@ dump_line_tables (Dwfl_Module *m, unwindsym_dump_context *c,
ehdr = gelf_getehdr(elf, &ehdr_mem);
while ((scn = elf_nextscn(elf, scn)))
{
+ const char *sh_name;
shdr = gelf_getshdr(scn, &shdr_mem);
- if (strcmp(elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name),
- ".debug_line") == 0)
+ sh_name = elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name);
+ // decompression is done via dwarf_begin_elf / global_read / check_section
+ // / elf_compress_gnu / __libelf_decompress in libelf/elf_compress_gnu.c
+ if (strcmp(sh_name, ".debug_line") == 0
+ || strcmp(sh_name, ".zdebug_line") == 0)
{
data = elf_rawdata(scn, NULL);
if (dump_line_tables_check(data->d_buf, data->d_size) == DWARF_CB_ABORT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment