From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QSV7Fcdqt2oGOgYAWB0awg (envelope-from ) for ; Sat, 26 Sep 2026 02:48:39 -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=E2umc1QC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 501841E033; Sat, 26 Sep 2026 02:48:39 -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 738F11E033 for ; Sat, 26 Sep 2026 02:48:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9EFE34B920F1 for ; Sat, 26 Sep 2026 06:48:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EFE34B920F1 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=E2umc1QC Received: from mail-wm2-x11.google.com (mail-wm2-x11.google.com [IPv6:2a00:1450:4864:31::11]) by sourceware.org (Postfix) with ESMTPS id F1D5D4BB593C for ; Sat, 26 Sep 2026 06:48:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F1D5D4BB593C 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 F1D5D4BB593C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:31::11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790405287; cv=none; b=JZ5wFf/GlKGUjD9MhhGw8JmS4BU0D6Fbnl3STx63lonuTBEiO4s6nfUFQpQ8CAGwM/BdJjlTtee7fjz6qftojs8j9ZJ2u/Xc9Ud7Mbem+85KBY55KKZ9Sz3Hid3nzxm3jt1ltCEiVeNO2Y+UZ4UcFf8jr/iiK51OerMgtbFfwMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790405287; c=relaxed/simple; bh=hbovAGaclRbdTK5ZASqGJCyv5h63FF9v7sqp20DHisY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wYBtjgaQNMdbnVCJeIZdNcYhPOZGBMDtPrAtNztoxv55OSZxKpuMlJG+MQjfzljaQ1IEk5A3KJahyMI4Y1sS5PLMlKhKcQRAwYuANYHDzDHE46TMaSTeGJFx2EMdn3DQVdWMG/hs6zfXQt8uWrfYx48bc3BjZSnFnMQg3+gw4jo= 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=E2umc1QC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1D5D4BB593C Received: by mail-wm2-x11.google.com with SMTP id 5b1f17b1804b1-49b912d3920so11397525e9.1 for ; Fri, 25 Sep 2026 23:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790405286; x=1791010086; 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=84mCu7wRPQXoLHTcRMqUqVZAWp4nJYxzBiOPc2zguik=; b=E2umc1QCwCKv48Gk+lXEbTjuNtpYBpjuR98aJhBdTlxFXUaGhyIlKOG2bH5VS0ZbDD 8Ljw0nI6XUSA1X6URFN6iA8UyTQ+pdKmzN6Dy5gG0vw3pOB2PpM4es4dBXgGzoUS872v tg/H6U6pFe4H1frZcT4L3mrxjLzLL768eRdFwqlSTlQxE8yMw47Il+3v3W9AanQkCCiG 5AUyvrrbpQVmrwKVZYwuT0CLbAlYw019O0vvQdCFP1BL0RuSmwwOZVrSFtc7D50/6BMp 0zCDFX48wVrf2H1E95LRGuDMJCXsICRLxLM6u3HexYE4jzVnakUtAMgBNVCfu8cTqiRc zC1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790405286; x=1791010086; 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=84mCu7wRPQXoLHTcRMqUqVZAWp4nJYxzBiOPc2zguik=; b=2vYAsHMY7gWm2HLBoq4lwTQyrKNhd+ajA1LsEOAltrM1ZQZYamcrvsc3GIR3sQNopg WjB9PKcc4edcOKC75gt3gSZFoNXx2RaI61sqQsSR5BEU9tgNVNHF0OnvlCJ/JHnFuyuk /xp/huweCfZO5cGvAER28BJVrSDmLhgEnj35Yt5GFrD6WRsifbgilh8p7YN7HQAsyB8U I5Uprz+bi7HM/toqH7ZjTbZbEuSAp+SL47hmBsFlRPUpMXOFknjGJnwR95CfyYKVcXAJ JCQkTiycNixAgH0Bi6/aDVYtX9XLFZSGyj3z8byHaFqXw6hngITsCtl1DBhfte8bIC6K xdjA== X-Gm-Message-State: AFuF++mNsMTK9VmztysUGP0cRhmjjsYKa/0hHgMLGfbjG9ldUooPgaC/ 360xX+IRLvOSd3vtdq4m9Bx3m1zC/e9aL4rHnwvsB0fzhbH9aEgHQqO0wbBroBE= X-Gm-Gg: AYBFou3WfQ8qPF6Ito/8Y30y9K+lmKGbZPBiCma6Mrrtksxp7Z7zTL8Mo7W8DC2PnwX 1KfWQWD8bSo2K7lp5kEsRzUdgUyfkOG6IdQ3EScpYIt7OziDlOTjel0jBR+oyjJjQVYOPFEPriz d0HWVWKJD7hNlmSVGYBfdC+PIerqWCoskA783V/3lcE/0gl/sz/8pQwGC7ftZQ10+xnaE/PsnDY iZbe9GmT8mPK+lTigBPsvjZtWPvqJ3wV0yILJ1ES2w7tBHgIUprQpLIrM3xv3S1k/aSrfEtD2TN KFI8X1g9CDYV/F5KVyG4qcQAkSapSayy250e69xkaHWRKaT24DLDRHYMlg6uU/Sq0RobnLzQkZT zjxeaCG0N1wzwJeAL5KQiyupk6p2paM68siU6nIQH+5q1lQjnthefPbzpGCo8rimrtz1g7/zJvO JG+Jb/iS6ptkZM+aR9bg2Hh/2/cB2QmThnc1wOtWxJ2OZvDgoYkaKpcZS/zrqLYMW4XBTChO7zd 7bFyIId6Y1+YQxfl8PnLWtTvy46e0Lf9Umk6EIMHmPg72rKED/K3shZPR6rVaygYT/whio= X-Received: by 2002:a05:600c:37c6:b0:49e:81db:4926 with SMTP id 5b1f17b1804b1-49fe66ca0d1mr135706055e9.5.1790405285623; Fri, 25 Sep 2026 23:48:05 -0700 (PDT) Received: from dragorn421pc.home (2a01cb0c8b3676002a37402cbc062626.ipv6.abo.wanadoo.fr. [2a01:cb0c:8b36:7600:2a37:402c:bc06:2626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49ff023f12esm110012875e9.0.2026.09.25.23.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2026 23:48:05 -0700 (PDT) From: Dragorn421 To: gdb-patches@sourceware.org Cc: Dragorn421 Subject: [PATCH v4 2/2] `add-symbol-file`: add test for mixing -o and -s Date: Sat, 26 Sep 2026 08:47:24 +0200 Message-ID: <20260926064742.29327-3-dragorn421@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260926064742.29327-1-dragorn421@gmail.com> References: <20260926064742.29327-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 | 71 ++++++++++++++++++++++ 2 files changed, 99 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..6759ef04746 --- /dev/null +++ b/gdb/testsuite/gdb.base/relocate_linked.exp @@ -0,0 +1,71 @@ +# Copyright 2010-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 +} + +set board [target_info name] +if {[board_info $board exists mathlib]} { + set saved_mathlib [board_info $board mathlib] + set_board_info mathlib "" + set err [gdb_compile "${binfile}.o" "${binfile}.plf" executable \ + {additional_flags=-nostdlib ldflags=-Wl,-r}] + set_board_info mathlib $saved_mathlib +} else { + set_board_info mathlib "" + set err [gdb_compile "${binfile}.o" "${binfile}.plf" executable \ + {additional_flags=-nostdlib ldflags=-Wl,-r}] + unset_board_info mathlib +} +if { $err != "" } { + 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" + } +} -- 2.43.0