From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /qGvIRckiGpihzMAWB0awg (envelope-from ) for ; Fri, 21 Aug 2026 06:10:31 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=ACzgqMw5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7584C1E033; Fri, 21 Aug 2026 06:10:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 26F171E033 for ; Fri, 21 Aug 2026 06:10:30 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2E824BB1C15 for ; Fri, 21 Aug 2026 10:10:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2E824BB1C15 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=ACzgqMw5 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 863BB4BA2E2E for ; Fri, 21 Aug 2026 10:10:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 863BB4BA2E2E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 863BB4BA2E2E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787307000; cv=none; b=sWN/iidiN66uW85DRMAtZrTNUtYGzkRduQjNwHUnFdKAoJJwYAGOTjTYz4qhc8PT7B9DvpKlL8/iNUOA6XtNHTUwU7dppfRM23S70O4EwuG4FjtpqbNIH2dB2UFgUpWWjpWWHPjpBAXzXJDkVQQhz8m/BQ8aMw3+aHU5neFv84U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787307000; c=relaxed/simple; bh=B/nHlrhTBb1B8DoRgX0w5GyrjIoMPAhM5QKXgbcc+Ag=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=oABRlIL2D+UK2//THfAQMl4vrTaS0LSnlxlzgoX88WYfWzp5oIFZSeELGUDAoSEDoRKuAuMItjl/5N3ZqzLvN4+ay2mySarTgwXuYuedzSTxfYgq59JI+wNrfUX08v8XajCRj4tlIXSyN9A4DrTLkiEPrhin82Cxx8WDFtQptTY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=ACzgqMw5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 863BB4BA2E2E Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-49978908b35so5417815e9.0 for ; Fri, 21 Aug 2026 03:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1787306999; x=1787911799; darn=sourceware.org; h=in-reply-to:autocrypt:from:content-language:references:cc:to :subject:user-agent:mime-version:date:message-id:content-type:from :to:cc:subject:date:message-id:reply-to:content-type; bh=eVjGbbRUQbp/qCdbLR/YVkmEGZSe6YQCwrO42voNH8o=; b=ACzgqMw5KXaP5mOT0f0CtIkh1gUuwF+gg90e/u4jeZzd1qWTI/R6AdxI/XxG9LepLt eMF2zm8urdKtK5sw4lGWkDO6wB4c2/JgSJc8HbomqXvTKUdThwBRIZ0IN+ZBP5HT7eLf 0fXl+e3Y7tsi+7Kx0xXsZqwvlQRx1agNlSLxiD+/5tr8ofNLtnaRrA0dBSMb2BizbvrP RYU4vGp8X8nWYSvH5RwXYEXSU1lvybmp2yfThlpfBdgy6BVaQ9jF3n9i9/hTmVgcvwWz vsdjueqalnXP1BoJQGFiiGkAIJv4v8O8+YgSAG83gK7eEZrwEMh992aaWZUHj2hiff3G yeLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787306999; x=1787911799; h=in-reply-to:autocrypt:from:content-language:references:cc:to :subject:user-agent:mime-version:date:message-id:content-type :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=eVjGbbRUQbp/qCdbLR/YVkmEGZSe6YQCwrO42voNH8o=; b=okDORwKlV8Dvt/amGTf5mzgLxj9I+CWkfIIW98eta05VvlqFZ8moablcwIQo7/vN2M ghBfkGx/FnGyV7ZuZUzszCEKVqcTYELop4qaXdS7zSf8JyJ8agGGO6HImM4qY1r5pGOg qUHbLz/svqw3G1kUsUCp65EwiLYijqTi8aBODJwQFP/pDNcMkAObHWgkShgh2UKCq/YW mCVxe2YjgIxGHqZsV2bAX4Fjxl/TytZRcjAWBQCuKwIqlJJkNYH8+UK/1xKsd/GjYnqA 9iCwyCm0zU9mVbTg5Bpu5kof/gUl3nobKhNOXzwkZkOTm5b/CPbOL9hGNlJ4GjRbRDHJ NfrQ== X-Forwarded-Encrypted: i=1; AHgh+RodBQGhIWIBDXEpamAF2kfWpdDjQnBur1F2XYKARX59s+FE0lqcyBOAE/2U0CMUsmrOlFAoumBdeGN55w==@sourceware.org X-Gm-Message-State: AOJu0YyhqwQiVuP6QhM1Yp4aOeVX+qVO/F7Zqu7/x28lN2Iq8mnQmURL uVA9DIhRXhAdJWxNfoJVrV5e1lZYVuYV7up4aYft/CxWuQpnudcdLN9DauVbB+ASLEs= X-Gm-Gg: AR+sD1300g4OqFN2m/YBgK/f5Nj41zMqkzZKUlegqEzreVgk3d5teZE9bNQyCU0Q3vk uzz8sy7vHWRIoSkXlQ1n2VLje5E/40nec68IiVt7jYpQLA5GRPyZ/XC79WOSfGyBhM2MooiUm6W o0/BtPmP1Wj8bX7K+xhYJpOEMUMqJmF45tEzNRPSG/980C6A7CNx4nyyAPAgYpHppZpRhvkqOrP 2ZeXl0BzuYJnn+2o5HrIS/zJmvqK241mvMePCoQueebQkuH4tMag0oPU99dctrN+77sy2H5Fmmv GiMtk8axaeQz3bp3YO/FS6oyYVlV75LiHPw5GjEcVmdlFEEA+CBLpvBszJWagvrQmbZQtsiaDKa PpUuYqtKgIpBIRnAYUH45h+T/TeNZPrU+sjOGnglWl3jBiD/6Fd0RDLSlTbu/OsGpQr5cUJMhlH RuBOxkRlOYRekjtEaWzvNujpA8AhteHfAKMWsCmVAwjJaKRSJ1d4tg7Rc9INaU6boXArYABol+5 ue7FSLuPRCL6iuH5mTtKulHxMT03CSx8P851ge6CVE27HMSX7lRYd2lOi+YFAVY X-Received: by 2002:a05:600c:3b08:b0:499:b402:6c0 with SMTP id 5b1f17b1804b1-499b830d671mr62645295e9.3.1787306999120; Fri, 21 Aug 2026 03:09:59 -0700 (PDT) Received: from [192.168.0.55] (sals-04-b2-v4wan-167965-cust660.vm36.cable.virginm.net. [80.3.10.149]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499b90e3138sm22783985e9.4.2026.08.21.03.09.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2026 03:09:57 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------QFbEhtgqC5AvYR2dDBv49d1G" Message-ID: <036b0f35-b8a4-40bb-ac57-42cb44628abc@embecosm.com> Date: Fri, 21 Aug 2026 11:09:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Add missing null pointer check in get_sal_arch To: Andrew Burgess , gdb-patches@sourceware.org Cc: Simon Cook References: <20260729150617.3502554-1-craig.blackmore@embecosm.com> <87ldarmfgy.fsf@redhat.com> Content-Language: en-US From: Craig Blackmore Autocrypt: addr=craig.blackmore@embecosm.com; keydata= xsBNBFdIF8oBCACwrsvc6YVfzJRT+ZoBfL9jEb8ITwNahDxCGSG6sIWrJ9UFeTwE8fnNhMpz RyFRm0OXruS5k/8YHJHrxKxFY9cgZ3CWNftXEjRqURUWGtN/ESiw0J7nVfhSGQTo3LBzpXZ1 0JHk4ZHKDJKYa+fhybCHOs19BfP3HydHoTlc5QTKMfom0X/xo7WDdwUYeZsjD9u8IzHk7gNw 05Abk1vqni+J7Fghjp4RI8W3IsjpKOfV3f02OyO/MTSraXNyejO4JRl0A8b3q1Lq+G6Z7o5n LVief5JpkRyzWQSawTIBKmRZa9EzAKZXd6IJdY/sZt7pTir5EP7MHq4a+AtKfKuDkrDDABEB AAHNLkNyYWlnIEJsYWNrbW9yZSA8Y3JhaWcuYmxhY2ttb3JlQGVtYmVjb3NtLmNvbT7CwHgE EwECACIFAldIF8oCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEGEeRQLLl5WtydMH /1nYd9jmOBaF8w5gGgjF5eOO5b/cdUegmO///VYj/5R7iF/zbB6KgF0Obo5h2gG9AIfsZG+T ybuTx7oU1DZYEIndw+YP9c9Yi5de5UzEHwbJiV57W0n+MP0Widgw7p6XJmUQ1XbHxdcWp7nY EJa8ASKLuuIhO8JFUXbQ8BcUiWbsA/JxgCzeid8iixGrzPWj6iFzoK2mX4GqP+24pXSDUamM TXmSQd2taYEsyUdJNiEkUC51ncRcMuThjdtfn6Ok+7lHjh3Zz8q0keJz5pnIp4EXdkAgKSjq U42PMrd3v1HoIFINTtr5F23OdkxoQzysu4GMO4pkw5pwz95Uckr08ojOwE0EV0gXygEIAKv/ luYHmCG/qefgzdbnegwMdG5753NJ+zGxFltFX6aaOPZ8go9Omf6zwjybUKv6Qx6AlDanwCl3 ewVQs+h9iW8uaQBRgeDmwAGMG/doBiFqs7X0jBf23exMiJezXlKb2ZlKzMAbzJ87408AzRaV sZdwEpXHVi2mRPoXtMrqL5iQEyG5hdx2ySj5164DIgVOs/ypFiaiFaDPkIcAQTzJrxsbt6pf iI9kT93DO9nRKVV0pPWztV8P5gKM8HY2rS0wQcfrqAU6T89Aa0VFw92J+w5d2spF8MUNPsvR NLm9ooCF3YME9STYHXrNH1U9fJUWpIC+b49UoWSWRD9nwl2h2i8AEQEAAcLAXwQYAQIACQUC V0gXygIbDAAKCRBhHkUCy5eVreLbB/sHPs1xu78uNV8O4UPTX7D5zBBS3nsrbDr+8stmXRap xbvo6kqKzIMAXuO3bYB/NyJ/tFzuFr9Tjd/2g56D2186bp01/kgxJ9CEl/m2T3lG3DlxIoLg pCExzTLTb8zH/7/6mdeJ17cdnrK+2QAKYctReVPAC67cq5KmUyU3bv5e1JzhV4ezz/i/O+Jv el112ZEsa54ya9KZOUHbgAR6hLnRWIa+8yQTtXqYRc3LxLRfS80Wn0Err1YvqFYzJsQMC8ND xAeEuqQ1gfk1b0jmv7tYljNqsHqzGVbuWz6hyzyLv5GjcdSDKpbw/797gRKQSY8Gty5ynfUH O4kKyuZPrE8P In-Reply-To: <87ldarmfgy.fsf@redhat.com> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This is a multi-part message in MIME format. --------------QFbEhtgqC5AvYR2dDBv49d1G Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Andrew, Thanks for the reviews. On 31/07/2026 14:54, Andrew Burgess wrote: > 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 moved the test to gdb.arch. > If this does work more widely then maybe a list of the targets it has > been confirmed to work on would be good. I have updated the test to work more widely and so far confirmed it works on arm, riscv and x86_64.  The patch below contains the updated test only - I will discuss how to proceed with the fix in my next reply. The test is now linked with -nostdlib to avoid linking library code that references specific symbols that would usually be defined in the linker script.  I have updated the linker script to ensure there are three LOAD segments, as at least three are needed to reproduce the issue. I have also included the cleanups suggested by you and Tom de Vries and fixed the strangely defined memory regions in the linker script. > 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 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. */ + +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. + +# 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. + + 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 +} --------------QFbEhtgqC5AvYR2dDBv49d1G Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi Andrew,

Thanks for the reviews.

On 31/07/2026 14:54, Andrew Burgess wrote:
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 moved the test to gdb.arch.

If this does work more widely then maybe a list of the targets it has
been confirmed to work on would be good.
I have updated the test to work more widely and so far confirmed it 
works on arm, riscv and x86_64.  The patch below contains the updated
test only - I will discuss how to proceed with the fix in my next reply.

The test is now linked with -nostdlib to avoid linking library code that
references specific symbols that would usually be defined in the linker
script.  I have updated the linker script to ensure there are three LOAD
segments, as at least three are needed to reproduce the issue.

I have also included the cleanups suggested by you and Tom de Vries and
fixed the strangely defined memory regions in the linker script.

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
+}

--------------QFbEhtgqC5AvYR2dDBv49d1G--