Hi Andrew,
Thanks for the reviews.
I have moved the test to gdb.arch.Isn't a test with a custom linker script, especially one that's placing text sections going to be architecture specific? I would have expected this to be a gdb.arch/ test?
I have updated the test to work more widely and so far confirmed itIf this does work more widely then maybe a list of the targets it has been confirmed to work on would be good.
You can push a `try` branch to sourceware into your username namespace, e.g. I could push to 'aburgess/try-my-awesome-fix' and the sourceware CI will spot this branch, run its tests, and email you the results. The key is the 'try-' part of the branch name. Though thinking about it, I'm not sure if it runs all tests, or just a subset, I guess you'd have to "try" it and find out.
I would like to try this but I don't have gdb write permission. I know I
need to send an email to admin-requests. Would you be willing to approve
me having write after approval access please?
Thanks,
Craig
---
commit 00c611b0c754a03c426af0e8476ee1e9347919e3
Author: Craig Blackmore <craig.blackmore@embecosm.com>
Date: Thu Aug 20 16:47:52 2026 +0100
[WIP] Updated testcase
This is the test case only. It does not include either fix.
diff --git a/gdb/testsuite/gdb.arch/bp-non-alloc.c b/gdb/testsuite/gdb.arch/bp-non-alloc.c
new file mode 100644
index 00000000000..2eb9f523887
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/bp-non-alloc.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int main ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/bp-non-alloc.exp b/gdb/testsuite/gdb.arch/bp-non-alloc.exp
new file mode 100644
index 00000000000..79f29dbb1da
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/bp-non-alloc.exp
@@ -0,0 +1,40 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that a breakpoint can be set on a function in an ELF file that has all
+# of the following properties:
+# 1. There is no section called ".text"
+# 2. The first section is non-allocatable
+# 3. There are three LOAD segments
+# This previously caused GDB to segfault due to attempting to dereference a null
+# objfile within a sal section.
+
+# This test has a custom linker script so may not work on all targets. It has
+# been confirmed to work on arm-none-eabi, riscv64-unknown-elf and
+# x64_64-linux-gnu.
+require {is_any_target "arm*-*-*" "riscv*-*-*" "x86_64*-*-*"} is_elf_target
+
+standard_testfile
+
+set linker_script $srcdir/$subdir/$testfile.ld
+
+set options "debug ldscript=-Wl,-T${linker_script} ldflags=-nostdlib"
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options]} {
+ return
+}
+
+# The executable does not support actually running, so we do not run to main
+# here.
+gdb_breakpoint main -message
diff --git a/gdb/testsuite/gdb.arch/bp-non-alloc.ld b/gdb/testsuite/gdb.arch/bp-non-alloc.ld
new file mode 100644
index 00000000000..73801e9f865
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/bp-non-alloc.ld
@@ -0,0 +1,42 @@
+/* Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This linker script is used to produce an executable that starts with a
+ non-allocatable section, does not contain a `.text` section and has three
+ LOAD segments. */
+
+MEMORY
+{
+ TEXT (rx) : ORIGIN = 0x80000000, LENGTH = 0x10000
+ DATA (rw) : ORIGIN = 0x80010000, LENGTH = 0x10000
+}
+
+PHDRS
+{
+ text PT_LOAD ;
+ data1 PT_LOAD ;
+ data2 PT_LOAD ;
+}
+
+SECTIONS
+{
+ . = SIZEOF_HEADERS;
+ .my_non_alloc_sec (INFO) : { . = . + 0x10; }
+ .text.all : { *(.text) } > TEXT :text
+ .data : { *(.data) } > DATA :data1
+ .bss : { *(.bss) } > DATA :data2
+}