From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id siRnNbxytWpDKj4AWB0awg (envelope-from ) for ; Thu, 24 Sep 2026 14:58:04 -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=RrDIPDnI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C7F5A1E06B; Thu, 24 Sep 2026 14:58:04 -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 CD82B1E01F for ; Thu, 24 Sep 2026 14:58:03 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 40B3B4BB58B6 for ; Thu, 24 Sep 2026 18:58:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40B3B4BB58B6 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=RrDIPDnI 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 958194BB58AB for ; Thu, 24 Sep 2026 18:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 958194BB58AB 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 958194BB58AB 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=1790276256; cv=none; b=q+/fL2t+zfOfnfm0+7S1r4OKkpqQe5CvmgZI+xjvfyS/26klinOpBr0kC2lRDU814KkClUVy7A7bdlXs+pzVjgmubRBHwTLXRtBPPXfWTLeTk5LZfLB2syClxHF02tXMBji9YHLPYzNQUhxuyhM6OHCBYTY6G1M1mjannFp7JY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790276256; c=relaxed/simple; bh=WiSSsDW7rNo+xWqcXd/JwoQfrLncsqxCrobKZcDpqAo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Rhs7zvoM+renPraWR8aZ28CANW6TuZ8auVvSiws3TXcsrqC0mvmODNheG5i2YIJPlievW05uhownW13Aquo3Nqpnnu4GJCkNFTBN9GT3RIx1itxW2c/O0WBuGKNz3+qCftsl2fYCo/vZ0yq3gfi4HGd2tFIQkftTfQVcVYa1pjM= 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=RrDIPDnI DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 958194BB58AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790276256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6DmtT+ECVwI3+8NcnyBnsNkZjFluZmWjBw3Qjnds6DE=; b=RrDIPDnIdJs7mZJKHPVc19HbLxgg6g80eF7iXZjk1zBK1l7+w7lVyn9Nzzkve46+VShnMQ iDoH3lTgGTTud+Fix9lee8umoRGd0WXK6Cr3RMBNYD3hqIce7vxC9AkL6+yNWKIR6Sxr9K 7iqE6FsCoJ93IO/dwmC5sr00h2J5lcs= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-510-LyC4q0etP3aUm2Wb4fLM0g-1; Thu, 24 Sep 2026 14:57:31 -0400 X-MC-Unique: LyC4q0etP3aUm2Wb4fLM0g-1 X-Mimecast-MFC-AGG-ID: LyC4q0etP3aUm2Wb4fLM0g_1790276251 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-53124d6a362so4139821cf.0 for ; Thu, 24 Sep 2026 11:57:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790276251; x=1790881051; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6DmtT+ECVwI3+8NcnyBnsNkZjFluZmWjBw3Qjnds6DE=; b=uxbpmbntv7fLySrk133mQHWDp5CoQSWzrW7QJVXsoBzWM7hrqNxFGOQ3rBBqtecb19 2QzfPVhHt/lqqg8dBXMSNCq4tykrUvAcw+ZgnT9ib7Em4ggb167zKDwLggZBdnVGCtKF Ft2L2pQOqLDrjnkNtCXl+Y2kIJGPeW+9xLDyYuG5bUSoopL+ZaAKBnubp7hqS4NE52Cf lvBdbJzJpTuTCSet6Wr5gfNP4Gw/zdJl7pZpUkuUtpEQ2dsjOLUUQCYM9nFy7rPvvnjW MUX4Q9i6RL2K8hhRwGETrm9IWlv6No7umcK/DIDF7UvLQMMiJYlGD9BU8H7cOp1dtRX1 QpwA== X-Forwarded-Encrypted: i=1; AKwUvBzbdp8HYN0ERYKeS2pumt7msl/HPyHp143YHkhwsvnFP7K3XbOT7a6702vw1jKDDoLrjYdaaJbwGXOzXg==@sourceware.org X-Gm-Message-State: AFuF++mRaL3HP9+Ui5fHMJS2AR/mxTyCsBryfodwzLi28bb/93/i8RKD bHL9aeR9g9UAApYCLxGZOAZx3ozhcljsXjbpo7a68IckuYsHM+umOWU/NRw9Kei2SG/KKSX7sRk WTwcVw/TTMwZo0QbNgJC+jt/tc/7PgRn+W47fyAOEGKtfvRN+fYqpDkd+d3zLgWJdhtCLiwI= X-Gm-Gg: AYBFou1wBu4UdcFtO9kPCL/ZLiFTZslkEVFTZ/c+6P9G3PV3g+z0UFakEKnzZHXxo0X QaSN/EzTQGB1qKRRTuFaSsOdhaKm7kk1bk/CUAp/pfCwa6PHbuxq+rxhpkJXzL5DpiP9G65j5iR GD0kW4uT/j1McWyvjw9PeDcKMr663lboFVbTAew7yNoOCGnO9/T6GySFGgBOS/iDLGKoMA+oEQx cIsDsEWr+LtDj1GUyOfD7Y9wM5AS++H+AtYasITgPOGcZuuy8inoHTbScF/HFnB/Kfecyj0QMuH hIoxq5RdrzWQHtggaXphUXkJrKwBAmFC6qce2zVNJIKBtzC+m4IGAt7q3vt3qi9psolsVBa+UOw nZXVmQWQ= X-Received: by 2002:a05:622a:144e:b0:52f:b627:608a with SMTP id d75a77b69052e-5330b602d39mr3850891cf.16.1790276250886; Thu, 24 Sep 2026 11:57:30 -0700 (PDT) X-Received: by 2002:a05:622a:144e:b0:52f:b627:608a with SMTP id d75a77b69052e-5330b602d39mr3850471cf.16.1790276250343; Thu, 24 Sep 2026 11:57:30 -0700 (PDT) Received: from [150.1.200.157] ([172.56.108.234]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5330c0e16easm210441cf.29.2026.09.24.11.57.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2026 11:57:29 -0700 (PDT) Message-ID: Date: Thu, 24 Sep 2026 11:57:28 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] `add-symbol-file`: add test for mixing -o and -s To: Dragorn421 , gdb-patches@sourceware.org References: <20260924035202.4533-1-dragorn421@gmail.com> <20260924035202.4533-3-dragorn421@gmail.com> From: Keith Seitz In-Reply-To: <20260924035202.4533-3-dragorn421@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LLWEMHo7-542bOV4sLr5LsiakpUgoz_niC-85aogKqM_1790276251 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Hi, Thank you for the test case! See my comments below. On 9/23/26 8:51 PM, Dragorn421 wrote: > 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 > +} > + Unfortunately, using target_link is problematic. It invokes bare ld while ignoring build flags such as -m32. When running the test suite in 32-bit mode: $ make check RUNTESTFLAGS="--target_board unix/-m32" TESTS=gdb.base/relocate_linked.exp ... ld: relocatable linking with relocations from format elf32-i386 (...) to format elf64-x86-64 (...) is not supported UNTESTED: gdb.base/relocate_linked.exp: failed to partially link It would be better to drive this through gdb_compile so that any target multilib flags are applied. Unfortunately, this gets a little complicated because of linking with the math library. I think it best to follow gdb.base/nostdlib.exp. Something like this on top of your patch seems a safer (and broader) approach: diff --git a/gdb/testsuite/gdb.base/relocate_linked.exp b/gdb/testsuite/gdb.base/relocate_linked.exp index 64c25dfab7b..69d715c86eb 100644 --- a/gdb/testsuite/gdb.base/relocate_linked.exp +++ b/gdb/testsuite/gdb.base/relocate_linked.exp @@ -24,7 +24,21 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug} untested "failed to compile" return } -if { [target_link "${binfile}.o" "${binfile}.plf" --relocatable] != "" } { + +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 } [I just copied that from nostdlib.exp.] > +# 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 > + } > +} This final 'pass' emits a misleading PASS. On an unpatched gdb, for example, we will mark both a FAIL and a PASS. gdb_assert will issue PASS/FAIL messages on its own, so I don't think this "pass $gdb_test_name" is needed. Keith