From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id d+V/MtKxbGr9rjcAWB0awg (envelope-from ) for ; Fri, 31 Jul 2026 10:31:46 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A84qIfnc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BB6E11E09E; Fri, 31 Jul 2026 10:31:46 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 E8D5D1E099 for ; Fri, 31 Jul 2026 10:31:45 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1511B4BCA415 for ; Fri, 31 Jul 2026 14:31:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1511B4BCA415 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A84qIfnc Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6589E4BC7EEF for ; Fri, 31 Jul 2026 14:31:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6589E4BC7EEF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6589E4BC7EEF Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785508276; cv=none; b=EcfcJqqYIrJJ/npL/dgA33f8YezQQS89DLrVxyXqUC1Zzzc1NneeEmeoOKZnSmMY8yHpi60sQtse2BCVXVBjwbUfwZuUj7AdrkmFO/wlGySfUTi3i/wNjr/fn4LXDp8nsuJGPz6k6tSwKMgSoo+6hD0ZnYhwRpTzyxWzEPeaww4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785508276; c=relaxed/simple; bh=sKdXnvR3LSKITgIuIXcMwhNzf2Qr0YosaJBVKXMkObM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hd0NPngo1AlXRgpUJwMOFhEs4QOrr/MzPkp8w5KM4U/+gyKU290sD8Qzd+DJfwR3l0x14QcXkOUgOOMApK/1fRhCw+smCpJiFAapWAyQamRd2yCi3HBGz5Zs/GY+7WsQXE6t2JB6yW5YqtkePMK6kcoq/hULUWpoJIhjIRaAseU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A84qIfnc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6589E4BC7EEF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785508276; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=plvm2vBJ1lQ2Xqftp5i3WV/tUidoC0w3bUOtJZBruRw=; b=A84qIfncRT6tfXUsiOOCz45gaSt2FqrBm1f0Bk3K3T2lyZAXJPJYnsYQlQE7qKF2fGYbws p3umK1HTb0qVdjYQu/WCo1HtPgSTlkZAfoWZIhuzj5WQlETC3pMX8K0+rG8sViGqcacNP8 VNSKNnx+3+xLbw8qii7W+54Ik2pM10k= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-3zf3nlmkNue8kBBXfab8tA-1; Fri, 31 Jul 2026 10:31:13 -0400 X-MC-Unique: 3zf3nlmkNue8kBBXfab8tA-1 X-Mimecast-MFC-AGG-ID: 3zf3nlmkNue8kBBXfab8tA_1785508272 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-47f753a0aa0so871899f8f.3 for ; Fri, 31 Jul 2026 07:31:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785508272; x=1786113072; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=plvm2vBJ1lQ2Xqftp5i3WV/tUidoC0w3bUOtJZBruRw=; b=ED2CxCIgQwocpZTa90fLx1WmY5imcHWFfQZv1E9BNeADiwCk51HZrjBRhubtDeTzhp m/BjXdmesR50YuIsw7ZSTehuDYxIi63Ezy6XdTA8v6sv8Lsl0dkupBTVkOGSZRY8rTDm L6jcBtXo78mp9ljVO/Q1jUTM1/e8fytZidWLPi2hFSsV5TFBRB6ds5idZ+iPF8wpVMVi 7+VHGdSCCx9VxigWW+9BMIFZzu38HhkQY7d7lTrNpJWhgVyFoMsoaoVo7bY4kTXXIGyQ DUNH36snlDmHhume8l556s7c2MXYH1v5VjGcisS0CcAA1sj6XWYkGytizSib1v27UTxz dJXQ== X-Forwarded-Encrypted: i=1; AHgh+Roq4aNWwBDW8RFjlEOYX7Rn32CpqqSm0wmVpMoBoVr7aTWuiQ4lf1vhAEdPsgtSATyrDRrj716sp1EN5w==@sourceware.org X-Gm-Message-State: AOJu0YzPc0Aq2S59/LYIHC3SBcbb1GMzjNSQTg6PlCgQK3bzi0o5Mg76 D3zTSqNoi1UMr6V8YQ44Vy+LJKWRAwCu+amGbuMDlNXIdxXhbgUrLFL+XmPdNcIkoVdIQgqnmGJ 2Df9KEvcEEbnlOn4lFdyVVYIHYGXy2IXtS0cLkqRfjmlogB+EV4m6qtl/DMKKDVjrNr06BiA= X-Gm-Gg: AR+sD11S/+Tvd5Lwqv1v+LcvMscqAOfzozJaF23TPyrvBBDUy0NjHKrpq/omuVzrwKM 8Jd38L7+DHmDAQjSRgInUYeKfZHtkN58UD7ntbF1uqV/vkjlvB1No3qOcQhhWqKCTOItsbEZJth SN2bbr0MwXjqq9TS9F+z37rX8QMCgP9iMpY9pbLuF+LLJ4U4fWero/ttFl/R5ouWaGWxAIQs8JW RCVXCckpRmJTDApnjxGjAHQiPNCS27p58CGPHXNAwBytMcNjmvoXs4m00O+QGYzKuZus9/tNEq4 9q5syB7Vw0zvZ78jCsBcwKWXU8Lo3PGv0VsTd/+s0dLBRJUvQqNJXNAwoXJy+szhAjiMZvitFBI BBvGGRjI1h2RoHZ8k X-Received: by 2002:a5d:5f42:0:b0:47d:efd0:c026 with SMTP id ffacd0b85a97d-47fd2ab7874mr5445418f8f.11.1785508271833; Fri, 31 Jul 2026 07:31:11 -0700 (PDT) X-Received: by 2002:a5d:5f42:0:b0:47d:efd0:c026 with SMTP id ffacd0b85a97d-47fd2ab7874mr5445348f8f.11.1785508271126; Fri, 31 Jul 2026 07:31:11 -0700 (PDT) Received: from localhost (92.6.93.209.dyn.plus.net. [209.93.6.92]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47fd41e2484sm5667749f8f.11.2026.07.31.07.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2026 07:31:10 -0700 (PDT) From: Andrew Burgess To: Craig Blackmore , gdb-patches@sourceware.org Cc: Craig Blackmore , Simon Cook Subject: Re: [PATCH] Add missing null pointer check in get_sal_arch In-Reply-To: <20260729150617.3502554-1-craig.blackmore@embecosm.com> References: <20260729150617.3502554-1-craig.blackmore@embecosm.com> Date: Fri, 31 Jul 2026 15:31:09 +0100 Message-ID: <87ik5vmdsi.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2Oqi9juRfMpcBWdJgAKzxhicx8A2GkJhzXifE1NDaQA_1785508272 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Craig Blackmore writes: > This fixes a GDB crash when trying to set a breakpoint on a function in > an ELF where there is both no .text section and the first section within > the ELF is not allocatable. This tells us WHAT happened, but not WHY. We understand the input as you gave a description of the ELF, and you explained the end result, a crash. But it would be really useful if you could fill in the middle bit. Why does the objfile end up as NULL? When a fix is "add a NULL pointer check" my immediate question is: should the pointer even be NULL? Maybe there's a better fix elsewhere in GDB which prevents the pointer from ever becoming NULL. The goal of the "middle bit" that I asked for above is to convince the reviewers that NULL is a valid possibility and that a NULL check should be added. This commit from April seems like it might be in a similar area of GDB: commit cd289df068e39683576f95907b5dd06ae3e4e254 Date: Wed Apr 15 10:43:31 2026 +0100 gdb: don't use .text as default entry point section and might be worth a read. > diff --git a/gdb/testsuite/gdb.base/bp-non-alloc.exp b/gdb/testsuite/gdb.base/bp-non-alloc.exp > new file mode 100644 > index 00000000000..7758a591fa7 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/bp-non-alloc.exp > @@ -0,0 +1,36 @@ > +# 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 . > + > +# For an ELF that has no section called ".text" and the first section is > +# non-alloc, test that a breakpoint can be set on a function. This previously > +# caused GDB to crash due to a missing null pointer check. > + > +require is_elf_target > + > +global srcdir > +global subdir > + > +standard_testfile > + > +set linker_script $srcdir/$subdir/$testfile.ld > + > +set options "debug ldscript=-Wl,-T${linker_script}" > +if {[build_executable "failed to prepare" $testfile $srcfile $options]} { > + return -1 The '-1' here can be dropped. > +} > + > +clean_restart $testfile > + > +gdb_test "break main" "Breakpoint .* at .*" > diff --git a/gdb/testsuite/gdb.base/bp-non-alloc.ld b/gdb/testsuite/gdb.base/bp-non-alloc.ld > new file mode 100644 > index 00000000000..6a8ad57af18 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/bp-non-alloc.ld > @@ -0,0 +1,35 @@ > +/* 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 and does not contain a `.text` section. */ > + > +MEMORY > +{ > + DATA (rw) : ORIGIN = 0x8000000, LENGTH = 0x10000 > + TEXT (rx) : ORIGIN = LENGTH (DATA), LENGTH = 0x10000 This seems a little strange. The ORIGIN of TET will be set to 0x10000 will it not? Which places TEXT before DATA. Now there's nothing wrong with that at all, but the ordering here seems weird. And also having the ORIGIN of TEXT depend on a LENGTH when it's going to be placed earlier in memory seems unnecessary, you'd be better just saying 'ORIGIN=0x10000' if that's what you mean. But maybe you actually meant something different? Thanks, Andrew > +} > + > +SECTIONS > +{ > + .my_non_alloc_sec (INFO) : { . = . + 0x10; } > + .text.all : { *(.text) } > TEXT > + .data : { *(.data) } > DATA > + _edata = .; > + .bss : { *(.bss) } > DATA > + _end = .; > +} > -- > 2.43.0