From: Simon Marchi <simark@simark.ca>
To: mlimber <mlimber@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [PR 25678] gdb crashes with "internal-error: sect_index_text not initialized" when .text
Date: Sat, 16 May 2020 17:05:42 -0400 [thread overview]
Message-ID: <bcc20b11-33ea-d94c-d9bb-039ce41b032d@simark.ca> (raw)
In-Reply-To: <CAAogRRrg-bEVefcVqFWhkhaYtGm210L=ZPgF6LZfCcEPQkGHZQ@mail.gmail.com>
On 2020-05-16 4:39 p.m., mlimber wrote:
> Thanks, with the comment you left on the issue and the attached libtestcase.so, I can repro it. However, neither of my two patches (which are basically the same anyway) fully fix it because it just bombs out later. More work required, which I'm willing to attempt.
>
> In the name of building all tests from source, can you advise on how to create an so like libtestcase.so? I've tried to fiddle with options and version scripts to no avail. My objdump looks close but not exact, and my attempts don't repro the error.
I was also looking at that right now.
The particularity of libtestcase.so is that it has a .debug_info section, so
the DWARF debug info reader (dwarf/read.c) kicks in to read the partial symbols
(a quick pass to read the debug symbols, to gather just enough things to build
some index of what's in it) but there is no .text section. The DWARF-reading
code assumes that there is a .text section, hence the failed assertion.
For reference, the DWARF in the file is the following:
.debug_info contents:
0x00000000: Compile Unit: length = 0x00000032 version = 0x0005 unit_type = DW_UT_compile abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000036)
0x0000000c: DW_TAG_compile_unit
DW_AT_name ("scratch.kyuu")
DW_AT_use_UTF8 (true)
0x0000001a: DW_TAG_variable
DW_AT_name ("foo")
DW_AT_external (0x00)
DW_AT_type (0x0000002e "s32")
DW_AT_location (DW_OP_addr 0x2250)
0x0000002e: DW_TAG_base_type
DW_AT_name ("s32")
DW_AT_encoding (DW_ATE_signed)
DW_AT_byte_size (0x04)
0x00000035: NULL
I am not sure how to end up there in a "legitimate" way. Even when I compile
a shared library with gcc with just a single global variable, a .text section is
created. So perhaps that was created with some particular options, or some other tool
In any case, GDB should be fixed, because even with some invalid / crafted input,
we shouldn't hit an assertion.
It shouldn't be difficult to craft an executable like this I suppose, just compile
a standard shared library with debug info and remove .text using objcopy? I don't
have time to try that right now.
For the test case that will go into gdb's testsuite, it can either be that (remove
the section using objcopy) or some manually-crafted DWARF (see other examples in
testsuite/gdb.dwarf2).
Simon
next prev parent reply other threads:[~2020-05-16 21:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 17:22 mlimber
2020-05-14 17:32 ` Simon Marchi
2020-05-14 17:48 ` mlimber
2020-05-14 17:57 ` Simon Marchi
2020-05-14 19:12 ` mlimber
2020-05-14 19:28 ` Simon Marchi
2020-05-15 18:33 ` mlimber
2020-05-16 20:39 ` mlimber
2020-05-16 21:05 ` Simon Marchi [this message]
2020-05-17 3:31 ` Simon Marchi
2020-05-17 7:01 ` Andreas Schwab
2020-05-17 14:01 ` Simon Marchi
2020-05-17 14:08 ` Simon Marchi
2020-05-18 18:01 ` Simon Marchi
2020-05-18 21:11 ` mlimber
2020-05-18 21:44 ` Simon Marchi
2020-05-19 14:36 ` mlimber
2020-05-19 14:44 ` Simon Marchi
2020-05-20 13:24 ` mlimber
2020-05-20 14:12 ` Simon Marchi
2020-05-20 15:04 ` mlimber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bcc20b11-33ea-d94c-d9bb-039ce41b032d@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=mlimber@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox