From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pbbqEZ+etGqmxToAWB0awg (envelope-from ) for ; Wed, 23 Sep 2026 23:53:03 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=hOSqFFiO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2B9F61E090; Wed, 23 Sep 2026 23:53:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 6FE9D1E04E for ; Wed, 23 Sep 2026 23:53:01 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2314A4BB3BEF for ; Thu, 24 Sep 2026 03:53:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2314A4BB3BEF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=hOSqFFiO Received: from mail-wm2-x10.google.com (mail-wm2-x10.google.com [IPv6:2a00:1450:4864:31::10]) by sourceware.org (Postfix) with ESMTPS id C09944BB3BDA for ; Thu, 24 Sep 2026 03:52:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C09944BB3BDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C09944BB3BDA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:31::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790221953; cv=none; b=CWQoTavPs/A4UaFG2hAXMke78gj94JJx5dwjup6cevZB65+MDpXMQn2mbmX9cLcgBlm+/4Nqn2G3aFuc+aSSpHSbaxVvPWK8phhoIjn/aQBnHYp44hTxuXo0BPrU0UcHF3clPO0thKK4DrS2/AsxfgXEUCHN79Prr8+tSklnWTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790221953; c=relaxed/simple; bh=19E/Tr7UJMizdG9Mpyom45ASI0vUVbZSeN1pXkj6P7A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q/9brEsN2N254wGh2xTtd1yOFNobt3Z1JNOHaXTaqO1EXsRDoJY4jlJtmLp1iHjemzpHWG0nTD/9Ozbziv1n6iRZW8q3o/WJRAS/zcjeHGz3dsKj8Iq1ghaDBl+sHcAZLCvys4gewtY4aCzAoWbNvkAwF24kNowohnFTBrswVH8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=hOSqFFiO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C09944BB3BDA Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49b91369d18so10697105e9.0 for ; Wed, 23 Sep 2026 20:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790221953; x=1790826753; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XVUtm1azWRKyoOIweXdd4Fxgty5fygflcu9RAPXi9AI=; b=hOSqFFiO3icToRlW2LO3Ep6bFE2tfBsU8T/XBLsASDgW+9CZPU60CBUj+Xb27++LhC w3RV+Q9tA9EiiF1kHa3EyPp+HW+Fzd4DV6s7+MbEWctCC/1aPcBGdwKwi+lI+XxIE+7d LXUT7QXe9RlHpqOtAtJhn4VUsz+CIyn8q/KhpJhBHakdL+EQqIQYlYwpc04QLEhyVVUR psZNnaFu1XBSdYtcJLkbVmk3IBH+HMgaR3o2rkUPWuWw3Z0YxoBWKcZNb9HnKBiJtFr3 Z59lwZE5OIqjZuDikVsElEUg9BqTXEB/kG6GkEMzTVciYptdpxsTH9MUwnnNv+Z4Hw2F qrIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790221953; x=1790826753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XVUtm1azWRKyoOIweXdd4Fxgty5fygflcu9RAPXi9AI=; b=usL4g57Pv9VTy2BXWKC/G3IvNQ/5yeuq5ZfhskSL3TZCSpXg05bw+GtwLqU/5HCWba LwWSMAyNBX48rQGWI8X4iLB5AmMVpaifr3TcKqSbz0hYrsA+Xv+qHO9GwvIyVpR4O+OO Yv7mjElO79nH9jtGnf/hFziHC9RxIldCUkxX4vJqDm72feMZAG636/C7Ci8VgyyGODHF k2/tY3DDLpkNG1ZS3TOnujuTrCwCE1UrXRyTXrQmqZWosrjHyRQ0TBCX3PswMrqNLWxY rCQbHGNogvG5ttB69/PbpCtCzplrFmMdvdukdGBRULKEzHaEeaeloiStAa9rjFm09iU+ 0EcQ== X-Gm-Message-State: AFuF++l9L548ftOZdD8ABSUKt0L7RHhh9ck7+Uw357VgkbmE5EDXFHVl OyVISTrqhbL5V2NvnsVrTtRLwilDsF2hwQd339PPHsuMJfDm27Mt9MTsbuJQMGk= X-Gm-Gg: AYBFou2lrXmOGDZ2ua3rcFipbqTvlIsUXdY3ycqm3Kf+ttvTfSn2cT+A24QLwr4tCQW YaSwXyb4ghiEEfYfKxeWq8NW3WZqH71DHe8wDZwKxTUB+oKH9yiLtk5oLVPgxDpQmiWfr5VJ+lo zL1uxaO3LNR6acjImvshRHmSNyB/69rYS1nAmAWfRZt0/sK2uK9x0BIRbA4BFhXHCRHNEVKle9F 3+TIUP/h3q6VpRcybZJvFCfRpvsVNPNmwuPAHy1A9w0W3xKhpF/IUO6830FDzO/IQDeHPSsAYvf b8qXqA8PWLRwFgm+Hhko5mnS2Kly2c8OiLuvQof54enEnRSJOvMPi7YEzHm3KEI4HLA/ZIA6zKn 9k/+A86yKqd7oAwuhe/5gNHXiLxOvpexVac+gTay2s9bWqjHYOIQR52paJqXNfJsoco60awlg1I tdyxgMB6OvJSzx+c8ikmqMEixWemZ+oImoeJ9DK+qO8ZTX4nc5NHlLT0PW7JuRVASSUDj/ep11I Lf+D1cL1vulYWWzIkExcwTS13Pi8bKDKWnhX4UinamYqA7CoAvU9DMxt5DJdWOlL/UZBtA= X-Received: by 2002:a05:600c:6092:b0:49e:7c4b:1753 with SMTP id 5b1f17b1804b1-49fe66c6365mr15376205e9.12.1790221952429; Wed, 23 Sep 2026 20:52:32 -0700 (PDT) Received: from dragorn421pc.home (2a01cb0c8b36760075f631915ba675a2.ipv6.abo.wanadoo.fr. [2a01:cb0c:8b36:7600:75f6:3191:5ba6:75a2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fe0c5c41asm81524955e9.4.2026.09.23.20.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 20:52:32 -0700 (PDT) From: Dragorn421 To: gdb-patches@sourceware.org Cc: Dragorn421 Subject: [PATCH v3 2/2] `add-symbol-file`: add test for mixing -o and -s Date: Thu, 24 Sep 2026 05:51:26 +0200 Message-ID: <20260924035202.4533-3-dragorn421@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260924035202.4533-1-dragorn421@gmail.com> References: <20260924035202.4533-1-dragorn421@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The test makes use of a built .plf (partially linked file) file, which is needed to exhibit the previously fixed bug, as unlinked .o object files only have 0 as address for their sections. --- gdb/testsuite/gdb.base/relocate_linked.c | 28 +++++++++++ gdb/testsuite/gdb.base/relocate_linked.exp | 58 ++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 gdb/testsuite/gdb.base/relocate_linked.c create mode 100644 gdb/testsuite/gdb.base/relocate_linked.exp diff --git a/gdb/testsuite/gdb.base/relocate_linked.c b/gdb/testsuite/gdb.base/relocate_linked.c new file mode 100644 index 00000000000..ac48ea28dc0 --- /dev/null +++ b/gdb/testsuite/gdb.base/relocate_linked.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 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 . */ + +int +text () +{ + return 0; +} + +int data = 1; + +const int rodata = 2; + +int bss; diff --git a/gdb/testsuite/gdb.base/relocate_linked.exp b/gdb/testsuite/gdb.base/relocate_linked.exp new file mode 100644 index 00000000000..64c25dfab7b --- /dev/null +++ b/gdb/testsuite/gdb.base/relocate_linked.exp @@ -0,0 +1,58 @@ +# Copyright 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 . */ + +# relocate_linked.exp -- Expect script to test loading symbols from linked +# relocatable object files (also known as partially linked files). + +standard_testfile .c + +# plf stands for "partially linked file" +remote_exec build "rm -f ${binfile}.o ${binfile}.plf" +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } { + untested "failed to compile" + return +} +if { [target_link "${binfile}.o" "${binfile}.plf" --relocatable] != "" } { + untested "failed to partially link" + return +} + +# Check that the -s address is respected when -o is used. +clean_restart +set offset 0xff000000 +set offset_re 0x0*ff000000 +set data 0x12340 +set data_re 0x0*12340 +set saw_data_section_with_correct_address 0 +gdb_test_multiple "add-symbol-file $binfile.plf -o $offset -s .data $data" \ + "add-symbol-file with offset and explicit data section address" { + -re "add symbol table from file .*${testfile}\\.plf.*at\[ \\t\\r\\n\]+\\.data_addr = ${data_re}\[\\r\\n\]+with other sections offset by ${offset_re}\[\\r\\n\]+\\(y or n\\) " { + send_gdb "y\n" + exp_continue + } + -re "Reading symbols from .*\\.\\.\\.\\r\\n$gdb_prompt " { + send_gdb "maint info sections -all-objects\n" + exp_continue + } + -re "$data_re->$hex .*: \\.data" { + set saw_data_section_with_correct_address 1 + exp_continue + } + -re -wrap "" { + gdb_assert { $saw_data_section_with_correct_address } \ + "explicit .data section address is preserved" + pass $gdb_test_name + } +} -- 2.43.0