mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
gdb: fix loading compressed scripts from .debug_gdb_scripts-section
The function `gdb_bfd_get_full_section_contents` doesn't implement
decompressing debug sections. This regresses loading `.debug_gdb_scripts`-section
from ELFs that were built with `-ggdb -Wa,--compress-debug-sections`
giving the following warnings on load:
warning: BFD: /home/ma27/.cache/debuginfod_client/8284e3a74f442359679ee97e96ee1c434e4479b7/debuginfo: unable to get decompressed section .debug_gdb_scripts
warning: Couldn't read .debug_gdb_scripts section of /home/ma27/.cache/debuginfod_client/8284e3a74f442359679ee97e96ee1c434e4479b7/debuginfo
The problem can be reproduced with a `test.cc` like this:
__asm__(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
".ascii \"\\4gdb.inlined-script.BOOST_OUTCOME_INLINE_GDB_PRETTY_PRINTER_H\\n\"\n"
".ascii \"import gdb.printing\\n\"\n"
".ascii \"import os\\n\"\n"
/* a sufficiently long script such that it gets actually
compressed */
".byte 0\n"
".popsection\n");
#include <iostream>
int main(void) {
std::cout << "hello world\n";
return 0;
}
I compiled the file with
`g++ test.cc -o test-program -ggdb -Wa,--compress-debug-sections` (GCC
version 14.3.0).
As suggested, this refactors gdb_bfd_get_full_section_contents to use
bfd_get_full_section_contents which implements decompression.
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
committed by
Tom Tromey
parent
3cdc2743c6
commit
8eb1701823
@@ -1103,12 +1103,12 @@ gdb_bfd_get_full_section_contents (bfd *abfd, asection *section,
|
||||
gdb_bfd_data *gdata = (gdb_bfd_data *) bfd_usrdata (abfd);
|
||||
gdb::lock_guard<gdb::mutex> guard (gdata->per_bfd_mutex);
|
||||
|
||||
bfd_size_type section_size = bfd_section_size (section);
|
||||
bfd_size_type section_size = bfd_get_section_alloc_size (abfd, section);
|
||||
|
||||
contents->resize (section_size);
|
||||
|
||||
return bfd_get_section_contents (abfd, section, contents->data (), 0,
|
||||
section_size);
|
||||
auto data = contents->data ();
|
||||
return bfd_get_full_section_contents (abfd, section, &data);
|
||||
}
|
||||
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
Reference in New Issue
Block a user