From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GWGAFUg0smowvjEAWB0awg (envelope-from ) for ; Tue, 22 Sep 2026 03:54:48 -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=LRL9NPqK; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 535B41E06B; Tue, 22 Sep 2026 03:54:48 -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,FREEMAIL_FROM,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 B15271E033 for ; Tue, 22 Sep 2026 03:54:47 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3456A4BAE7DC for ; Tue, 22 Sep 2026 07:54:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3456A4BAE7DC 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=LRL9NPqK 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 49C8C4BAE7D6 for ; Tue, 22 Sep 2026 07:54:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49C8C4BAE7D6 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 49C8C4BAE7D6 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=1790063651; cv=none; b=Pp07i8p5TNBNs19YCDQHQhihl8hl7kM0oarZW+IB9N9YvX3ZoWzgsoJZ2SA59Wm9Cy+d84BXtkC7CzUK6nhgWHaHgete5BcLqBLDd/6xlhzuCTBwNHSvaOnSfVIXRQ6qE8C7r9EXXGoXLpCe8ymNZCCA/IVPOcvGsj9kh67WJv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790063651; c=relaxed/simple; bh=bCmgaXn27RIUfduyeZWS+LEo6nT0n+1f/MnyqZKoy7Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DJ3rmDZl2iocwqdtkjeEtZVlqt6fDWZnl9VRCE6D0SBRkUqWb4Hreg0byV45izePCcFNNjE5PVqJCXONC3yBCpa4k3z7gsYPvFNw6dvhFVSvud5JKyP1rPrkNQLBlIbcxbcaFilPuNYLhFDwpxJbODCeP1Xzhbqfkl0e185sYUs= 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=LRL9NPqK DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49C8C4BAE7D6 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49b912e4b11so20493135e9.3 for ; Tue, 22 Sep 2026 00:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790063650; x=1790668450; 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=pMfme4nWRmF2btqcPT8CZ/mMYLsCFxdC9nd5K2SHO+s=; b=LRL9NPqK2+HunbtCYnWY00Y+i7yuIJjE7BgGdXNhP56oVhGLfsM4XFz7IbtaEIZPLS /vdB3h0zryfsexFNmSOeOu+O2mq+0sdjwQ8+JDYAvPGfe4IW3QlraeAifSwDcHxlF2wc ttiCjASDS7kRuwwd59nWj2lhIpsA/V1jPyahvqZoV4J1Ln+6IB0rHaPoRjpNfWcQ4Kaf Aa0E5UtIq0rGBnkjHAYWsIBaQcSXkjzjefOjKgYed5lL0dp/i29g35zNvhFwP4QiTNAs dAb/W2ozobGm0cEvxhvP6JwA1k2F4beJ3HABE+jkHP9ErPDy3z1OJi8DIwkrO7Nyd/0N D/rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790063650; x=1790668450; 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=pMfme4nWRmF2btqcPT8CZ/mMYLsCFxdC9nd5K2SHO+s=; b=JLwfBcG8Z8J3Tiv1x+9FTrde2T6yQCOfqhq1y0NB5EnozhL5KK+m7qNnqz6LtNfnT9 k0GImQ/5Th97Dk6HZAAE79wqCoYQPNaKWVbzNRP9eeYGZ9oabhMB3ytFndXNmSElSvcU xsq1nEy4gF/7JDxZNdEKIF+MopD/Hl6scMclgbXS+a098C+JFWGeIYPMljT9qePSWpBa wzH9m4j26Lal4s9Z6N9bDQ59M58dt+ult6B3Z/BnMS/8TZN58NZEQb5O45fm+S6423PJ lB5a5U3qv7OdKrMwjB8Hj6zzH2+uT+zHR6rB+Nd4LSrcKlfjMkzI76Cf8295rgCv/r3u vsYg== X-Gm-Message-State: AFuF++l93acsV9J16C3RdbWKFsEt02gooi+72N8Q4pZmZiBSZe2VPm78 4SBAfPQxX85/B71h7tEksFOH5QYrV3vfC7ugZquALK9OO3j4ckDWkKa+pkYR1bQ= X-Gm-Gg: AYBFou3+ZSxMTUEf4EtuzJuWy08mKRGB+M8Xc/i6gy7r1q25m9kMB99ynilwJ4Ofr0H S0RK/fDK6ZUo9feBFPZEVVCvWpgFFgPrTjujf4TeTBEdBFH4pKyTCO2zI3gsoNrBap5s+5vFyN4 SiFOtybxLREUr7CodmfLDeHQQmpk/CDbvgjPH07nTL9NP9SsKOO3xZ0G2cD0wSmT4v1lUP+vn+P UYaJ7ILQ3eGfZYLjonVhEz2dOV3Iyfp5vJVgwwEyvc8/zQWtRffKaiwUb7yxomfAB7Uxy3QLKJS hJuyjR9uRz/TRNpdbfk6Z9d64a3k0zo3zm0cLB769Vkt6wi8KWTPbMAv6ZLAo1ghBFRWrAWEH/j yn27zSZD6UE3VLqzFrObXqgypo9aHsJTSAFON0OFFL0NnhM17hbKMl0ORLcYZ3ZGmEGA/oxJLwp VlTQ45z6vR+CIoI13w6LpTLUwCGXjWKIP3f8RJKi1rO6xuGQBXfgw4rgJaBgGkeLZM2zItaOeaw VIXQficAoXRa3TT2DRV8bHQPkmzO/70X5xCUiHWcZ3WorAQ0VPB7ie2NzrUkPJLVgyedXeP X-Received: by 2002:a05:600c:8b21:b0:49d:1df8:156d with SMTP id 5b1f17b1804b1-49fc574f001mr182135335e9.18.1790063649939; Tue, 22 Sep 2026 00:54:09 -0700 (PDT) Received: from dragorn421pc.home (2a01cb0c8b36760068aa4f15600854a7.ipv6.abo.wanadoo.fr. [2a01:cb0c:8b36:7600:68aa:4f15:6008:54a7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fd8cc05e9sm54554125e9.5.2026.09.22.00.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 00:54:09 -0700 (PDT) From: Dragorn421 To: gdb-patches@sourceware.org Cc: Dragorn421 Subject: [PATCH v2 2/2] Add test for mixing -o and -s Date: Tue, 22 Sep 2026 09:52:44 +0200 Message-ID: <20260922075252.104346-4-dragorn421@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260922075252.104346-2-dragorn421@gmail.com> References: <20260922075252.104346-2-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 | 56 ++++++++++++++++++++++ 2 files changed, 84 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..969e36c6a4f --- /dev/null +++ b/gdb/testsuite/gdb.base/relocate_linked.exp @@ -0,0 +1,56 @@ +# 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 data 0x12340 +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}\[\\r\\n\]+with other sections offset by ${offset}\[\\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->$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