From patchwork Mon Dec 5 14:41:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 29700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2292794wrr; Mon, 5 Dec 2022 06:41:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Hh7JJbWpiwf4q9WmjftfokLioyAmD9bSTnG37aBd9LArQMZ2L4yK15xl8vkfxMjuR1a3X X-Received: by 2002:a17:906:9f09:b0:7bc:db1b:206f with SMTP id fy9-20020a1709069f0900b007bcdb1b206fmr5964058ejc.719.1670251274582; Mon, 05 Dec 2022 06:41:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670251274; cv=none; d=google.com; s=arc-20160816; b=aelsRW6C0Sj4Hrv+frpAeYnXIbbRVjpaDevv5+4xM1ivUaibbfKb/rI5/9fQfaVmuY bcIzxuadeNdtCX3dUpaIkPBx9/ch8VCASQ0wBTRQwrmxN781GcJDfAwxfUV8AVuh75lH ksZ2I9h4F9u0CO1mvXdlSE19xsnR1f5eMn2DKp91DZhyDONaWdjhJ7ntD3ajOaZ0OaIi F8weOuYg8ATMx6yxswyslHRlI7by/tI0HWUKCSS3UfNfpXYmb2ivxVg5o7Zx+d4L5y3W wviRU7kM3jWCnkjnkVqJMUHDoe1RGdS9sAS/B7NSHRf/OyYNMjqd0cj7WVkXbC7VJqBl bptw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:content-language:references:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature :dmarc-filter:delivered-to; bh=ShRSSHigVauFZ32YxVpJvRaCXKWlFEUH+Hjh3lz+aQ0=; b=Fph6JW81mUP9kvD/sVrDJakj3DidiQ6dyV4we8AEDZkotWjYZcTAWgaZBkGdHsLQEh IBXqfA4gMcYQOxrqrp8j5/Icz8daTUIyqOeYPEVOF8PRFx+UhEo3loJ3GaAC7yP9bpVd z8tyg+zkGjdL7cId/c1irvNieC7bk9zqm0l9FG/R+Tu9bKYO2lvE588n9Llip0c4D8PG 7xnZHf7ZZqIqcUWl2LF7TEl0BFJhKS2bkvsV9ZLNethxkdDj3CO3ouCxcm/nV5rf8vvH f1xs9YxU1HEXFC0CPU9o6z5wqeorK9Kf/3xibYqBubygxWhc3RBhbKeG/BsTyAgWJtEd hLNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jZnhFMaD; dkim=neutral (no key) header.i=@sourceware.org header.b=hBw2C1kn; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c13-20020a170906340d00b00782161b3422si9410702ejb.914.2022.12.05.06.41.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 06:41:14 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jZnhFMaD; dkim=neutral (no key) header.i=@sourceware.org header.b=hBw2C1kn; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CC12393BA7F for ; Mon, 5 Dec 2022 14:41:13 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id AA684393A412 for ; Mon, 5 Dec 2022 14:41:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AA684393A412 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DD75F1FE40 for ; Mon, 5 Dec 2022 14:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1670251264; h=from:from:reply-to: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=ShRSSHigVauFZ32YxVpJvRaCXKWlFEUH+Hjh3lz+aQ0=; b=jZnhFMaDKQIqfgKbdMvgx2MBgd1xMXKd/Du+ZfXAKmCcJI0sjz++Z2pYM+Aj8pSerhnxZ7 +dBY+MqYpqaoaQ29Fkuj1bf2/zBqwGOB937mayxMLnBwEQwWbpXGjTgGAqCzDaOQm50uWO eYzAlcBUGygN9la7b9GwOQKRIHvGWls= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1670251264; h=from:from:reply-to: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=ShRSSHigVauFZ32YxVpJvRaCXKWlFEUH+Hjh3lz+aQ0=; b=hBw2C1knYCEQlOarQcqSHad2z/c+UvU/vXzETM090ceQi0KTrwPLvVL4NQferI6eiYHlWp tzM5Yu6eVPKkggAQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id CFDE51348F for ; Mon, 5 Dec 2022 14:41:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id dn7pMAADjmNZGgAAGKfGzw (envelope-from ) for ; Mon, 05 Dec 2022 14:41:04 +0000 Message-ID: <2eb01f7a-2430-b0bc-9c58-d15d06ca6bf9@suse.cz> Date: Mon, 5 Dec 2022 15:41:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH V3] testsuite: support mold linker To: binutils@sourceware.org References: Content-Language: en-US In-Reply-To: X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751375906601750942?= X-GMAIL-MSGID: =?utf-8?q?1751385400655234765?= Mold linker demotes symbols like main to be local and the patch adjusts expected output from nm. Moreover, simplify the regex patterns. --- binutils/testsuite/binutils-all/addr2line.exp | 4 ++-- binutils/testsuite/binutils-all/objcopy.exp | 6 ++---- libbacktrace/Makefile.am | 2 +- libbacktrace/Makefile.in | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/binutils-all/addr2line.exp index 66a2d5d32a0..957ae55df33 100644 --- a/binutils/testsuite/binutils-all/addr2line.exp +++ b/binutils/testsuite/binutils-all/addr2line.exp @@ -34,7 +34,7 @@ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug #testcase for default option. #Run nm command and input the main symbol address to addr2line. set output [binutils_run $NM "$opts tmpdir/testprog$exe"] -if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then { +if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then { fail "$testname" } else { set list [regexp -inline -all -- {\S+} $contents] @@ -49,7 +49,7 @@ if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then { #testcase for -f option. #Run nm command and input the fn function symbol address to addr2line. -if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}fn" $output contents] then { +if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then { fail "$testname -f option" } else { set list [regexp -inline -all -- {\S+} $contents] diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index de6f3aaaef2..e3388597f56 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -652,8 +652,7 @@ proc strip_test_with_saving_a_symbol { } { set exec_output [binutils_run $NM "$NMFLAGS $objfile"] set exec_output [prune_warnings $exec_output] - if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \ - && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} { + if {![regexp {^([0-9a-fA-F]+)?[ ]+[TtDd] _?main} $exec_output]} { fail $test return } @@ -902,8 +901,7 @@ proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } { regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output } - if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \ - && ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} { + if {![regexp {^([0-9a-fA-F]+)?[ ]+[TtDd] _?main} $exec_output]} { fail $test1 return } diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index 8874f41338a..bf9d30a382c 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -498,7 +498,7 @@ TESTS += mtest_minidebug %_minidebug: % $(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms - $(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms + $(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms $(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms $(OBJCOPY) --only-keep-debug $< $<.dbg $(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index 2ba8dfa8428..5167ca80ad1 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -2459,7 +2459,7 @@ uninstall-am: @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: % @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms -@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms +@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --only-keep-debug $< $<.dbg @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg