From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14975 invoked by alias); 8 Jan 2015 10:16:23 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 14964 invoked by uid 89); 8 Jan 2015 10:16:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 08 Jan 2015 10:16:20 +0000 Received: by mail-wi0-f178.google.com with SMTP id em10so2225414wid.5 for ; Thu, 08 Jan 2015 02:16:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=fW060v5nBAiWrW7m2jRRYldfX4jpuTnz59C1uMpnkzY=; b=mT0rN/AOkBS1sWGlT1MzFVMYvFfE0hWU0tAEvkrTGr262zyx2pubenNI1P6mp0FqqZ cJCPiM10tApjgH2AQh+lfPoumxUsN8NspXCdkji0KVL13HJIZg0ZypcHqQjJildy4yQ0 Uc6hZR+7ASul3Ttg0zCXPKcjiyVbJyz1jhAJRcSbKMKIzX+lRD4gfCt2DhRwCX1fNAj2 94ZR0CwyRoh0U9QjUDVXm5DxXVzYooN/wRA6J8rkS5bURn7QyE3aVBdTbDr4RfQ9rQLY IxDc7h2pm/9hbvBUt5BoHol6NCbOHqa4oeSByEYuOyQQFNV98SfelG47Sri+vIY6v2I8 xhCA== X-Gm-Message-State: ALoCoQnUyVRfxGzTaYruU0MYHIpihbZVXjjc2MaPh5NpykjsTG3le630uEdeslf//7lAyK0c/cJn X-Received: by 10.181.13.7 with SMTP id eu7mr18288214wid.72.1420712177308; Thu, 08 Jan 2015 02:16:17 -0800 (PST) Received: from localhost (host86-133-98-196.range86-133.btcentralplus.com. [86.133.98.196]) by mx.google.com with ESMTPSA id cg8sm5541920wjc.1.2015.01.08.02.16.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jan 2015 02:16:16 -0800 (PST) Date: Thu, 08 Jan 2015 10:16:00 -0000 From: Andrew Burgess To: binutils@sourceware.org Cc: Hans-Peter Nilsson Subject: Re: [PATCH 1/2] ld/testing: run_dump_test can now check linker mapfiles. Message-ID: <20150108101615.GF3103@embecosm.com> References: <83c76e053661eddd25742de29d39e07208b1b83e.1420631791.git.andrew.burgess@embecosm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00078.txt.bz2 * Hans-Peter Nilsson [2015-01-07 20:21:00 -0500]: > On Wed, 7 Jan 2015, Andrew Burgess wrote: > > > This is just a new mechanism to make it easier to test linker mapfiles. > > (Not an approver, but:) Cool. Just a few nits: Thanks for the review. I fixed the typo and copy-'n'-paste-o, however... > > Consider simplifying: always add it when "map:" is present. > (I just don't see the use in the more complex function. Keep > it simple.) ... I've left this in for now. My reasons being, first, I don't think it actually adds that much complexity (in fact, when I first wrote this I did always add the -Map, but had an error check to ensure that the user had not also specified -Map in the options, I realised I was 99% of the way to just using the users mapfile). As for use case, if a user wanted to perform any additional checks on the mapfile, the easiest way would be to just specify -Map in the ld flags. I guess if there's one more vote for remove it then I'm happy to do that. Updated patch below. Thanks, Andrew --- Add a new option 'map' to the ld run_dump_test mechanism. When the 'map' option is given run_dump_test will ensure that there is a -Map=MAPFILE present in the linker command line, adding one if needed. The MAPFILE is then compared with the file passed to the new 'map' option using the regexp_diff function. This should make it slightly easier to write tests that check the linker mapfile output. The only test I found that already compares mapfile content is updated to use the new mechanism. ld/testsuite/ChangeLog: * ld-scripts/overlay-size.d: Add 'map' option. * ld-scripts/overlay-size.exp: Remove manual check of mapfile. * lib/ld-lib.exp (run_dump_test): Add support for new 'map' option, checking linker mapfile output. --- ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-scripts/overlay-size.d | 1 + ld/testsuite/ld-scripts/overlay-size.exp | 9 --------- ld/testsuite/lib/ld-lib.exp | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index c9b3ecb..266e996 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-01-07 Andrew Burgess + + * ld-scripts/overlay-size.d: Add 'map' option. + * ld-scripts/overlay-size.exp: Remove manual check of mapfile. + * lib/ld-lib.exp (run_dump_test): Add support for new 'map' + option, checking linker mapfile output. + 2015-01-06 Andrew Burgess * lib/ld-lib.exp (run_dump_test): Extend comment to mention diff --git a/ld/testsuite/ld-scripts/overlay-size.d b/ld/testsuite/ld-scripts/overlay-size.d index 78a9c92..4e60150 100644 --- a/ld/testsuite/ld-scripts/overlay-size.d +++ b/ld/testsuite/ld-scripts/overlay-size.d @@ -1,6 +1,7 @@ # ld: -T overlay-size.t -Map tmpdir/overlay-size.map # name: overlay size # objdump: --headers +# map: overlay-size-map.d # xfail: rx-*-* # FAILS on the RX because the linker has to set LMA == VMA for the # Renesas loader. diff --git a/ld/testsuite/ld-scripts/overlay-size.exp b/ld/testsuite/ld-scripts/overlay-size.exp index 4dde289..e8e7a91 100644 --- a/ld/testsuite/ld-scripts/overlay-size.exp +++ b/ld/testsuite/ld-scripts/overlay-size.exp @@ -23,12 +23,3 @@ if ![is_elf_format] { } run_dump_test overlay-size - -set testname "overlay size (map check)" - -if [regexp_diff "tmpdir/overlay-size.map" \ - "$srcdir/$subdir/overlay-size-map.d"] { - fail $testname -} else { - pass $testname -} diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 3d980c9..0a25f86 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -555,6 +555,14 @@ proc ld_simple_link_defsyms {} { # both "error" and "warning". Multiple "warning" directives # append to the expected linker warning message. # +# map: FILE +# Adding this option will cause the linker to generate a linker +# map file, using the -Map=MAPFILE command line option. If +# there is no -Map=MAPFILE in the 'ld: FLAGS' then one will be +# added to the linker command line. The contents of the +# generated MAPFILE are then compared against the regexp lines +# in FILE using `regexp_diff' (see below for details). +# # Each option may occur at most once unless otherwise mentioned. # # After the option lines come regexp lines. `run_dump_test' calls @@ -607,6 +615,7 @@ proc run_dump_test { name {extra_options {}} } { set opts(warning) {} set opts(objcopy_linked_file) {} set opts(objcopy_objects) {} + set opts(map) {} foreach i $opt_array { set opt_name [lindex $i 0] @@ -860,6 +869,20 @@ proc run_dump_test { name {extra_options {}} } { set cmd "$LD $LDFLAGS -L$srcdir/$subdir \ $opts(ld) -o $objfile $objfiles $opts(ld_after_inputfiles)" + # If needed then check for, or add a -Map option. + set mapfile "" + if { $opts(map) != "" } then { + if { [regexp -- "-Map=(\[^ \]+)" $cmd all mapfile] } then { + # Found existing mapfile option + verbose -log "Existing mapfile '$mapfile' found" + } else { + # No mapfile option. + set mapfile "tmpdir/dump.map" + verbose -log "Adding mapfile '$mapfile'" + set cmd "$cmd -Map=$mapfile" + } + } + send_log "$cmd\n" set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "ld.tmp"] remote_upload host "ld.tmp" @@ -908,6 +931,17 @@ proc run_dump_test { name {extra_options {}} } { return } } + + if { $opts(map) != "" } then { + # Check the map file matches. + set map_pattern_file $srcdir/$subdir/$opts(map) + verbose -log "Compare '$mapfile' against '$map_pattern_file'" + if { [regexp_diff $mapfile $map_pattern_file] } then { + fail "$testname (map file check)" + } else { + pass "$testname (map file check)" + } + } } else { set objfile "tmpdir/dump0.o" } -- 1.9.3