diff options
author | Marian Buschsieweke <marian.buschsieweke@posteo.net> | 2023-06-02 09:25:55 +0200 |
---|---|---|
committer | alice <alice@ayaya.dev> | 2023-06-02 18:35:12 +0000 |
commit | 1e377ffea49ff2f3b24d064dd21a40edd8912d4e (patch) | |
tree | 6054d715cbc20c0f031840945ad266a48e768928 | |
parent | a33f8332502b7f9e2770c31ba3bde81489838b29 (diff) | |
download | aports-1e377ffea49ff2f3b24d064dd21a40edd8912d4e.zip |
main/gdb: fix segfault inspecting var on MCU
`obj_section->the_bfd_section` is dereferenced in
`language_defn::read_var_value()` without checking it for being `NULL`.
This causes a segfault when inspecting a variable (located in the
memory mapped I/O region) on a remote MSP430 embedded target connected
via JTAG.
This adds a trivial patch adding the `NULL` pointer check that fixes
the segfault.
See https://sourceware.org/bugzilla/show_bug.cgi?id=30431 for details.
-rw-r--r-- | main/gdb/APKBUILD | 4 | ||||
-rw-r--r-- | main/gdb/fix-segfault-dereferencing-the_bfd_section.patch | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/main/gdb/APKBUILD b/main/gdb/APKBUILD index 354beab8a31..1298c20bbd5 100644 --- a/main/gdb/APKBUILD +++ b/main/gdb/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=gdb pkgver=13.2 -pkgrel=0 +pkgrel=1 pkgdesc="The GNU Debugger" url="https://www.gnu.org/software/gdb/" arch="all" @@ -29,6 +29,7 @@ source="https://ftp.gnu.org/gnu/gdb/gdb-$pkgver.tar.xz ppc-musl.patch ppc-ptregs.patch musl-signals.patch + fix-segfault-dereferencing-the_bfd_section.patch " prepare() { @@ -114,4 +115,5 @@ sha512sums=" 04911f87904b62dd7662435f9182b20485afb29ddb3d6398a9d31fef13495f7b70639c77fdae3a40e2775e270d7cd40d0cfd7ddf832372b506808d33c8301e01 ppc-musl.patch ab554899bbb2aa98261fd1b6beb4a71ed7c713a714bddd3fa7ec875258e39bd5474dc96a11accb4dadd316f3834f215e8395d3b373bf3affd122dc5b4a8fe710 ppc-ptregs.patch 58aacc7cdc119eab729a3c5a5521f6a0db41c6a5bc2d09d6e32cbdd071d85dd1a31b5e6559616f8da1237c5b79ad9e04aab485211e957b4d1ca752c0c5ad660b musl-signals.patch +ae0de066cbf167b8da0c9787441c86ca2afc67e269605734b36337092a14a2e74a56e560837d17db2eec431a5f46dcf31014f0917929266b1a9e150108f1c4eb fix-segfault-dereferencing-the_bfd_section.patch " diff --git a/main/gdb/fix-segfault-dereferencing-the_bfd_section.patch b/main/gdb/fix-segfault-dereferencing-the_bfd_section.patch new file mode 100644 index 00000000000..6c14c6afe85 --- /dev/null +++ b/main/gdb/fix-segfault-dereferencing-the_bfd_section.patch @@ -0,0 +1,25 @@ +Fixes a segfault when printing a variable with obj_section->the_bfd_section +being NULL. + +See https://sourceware.org/bugzilla/show_bug.cgi?id=30431 for details. +--- a/gdb/findvar.c ++++ b/gdb/findvar.c +@@ -752,15 +752,15 @@ + obj_section = bmsym.minsym->obj_section (bmsym.objfile); + /* Relocate address, unless there is no section or the variable is + a TLS variable. */ +- if (obj_section == NULL +- || (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) ++ if (obj_section == NULL || ++ (obj_section->the_bfd_section && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)) + addr = bmsym.minsym->value_raw_address (); + else + addr = bmsym.value_address (); + if (overlay_debugging) + addr = symbol_overlayed_address (addr, obj_section); + /* Determine address of TLS variable. */ +- if (obj_section ++ if (obj_section && obj_section->the_bfd_section + && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) + addr = target_translate_tls_address (obj_section->objfile, addr); + } |