From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 4095F3858D38 for ; Thu, 26 Jan 2023 00:38:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4095F3858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=harmstone.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x429.google.com with SMTP id y1so274782wru.2 for ; Wed, 25 Jan 2023 16:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=v0WJukgTLOjialbbq4s4zJU7nr7whkAt/u15ZCMUhUo=; b=ChWMlrdCtJ/9p7X4/Zt8extc2lHuiC8O89ZSWiBPYBp/fzybgsnZCJfNfDvoH+k0My CTidiudr/mEI91it92/9ItAvgxiRxn7SeDn5t9kRE+VfHFSCvdYknHSSJQ0zT2yycHsZ QbqYIN/D2rTP/xpOx+HgDiQ6eS3tRfpgt/x5M+ztkXcRIV01WziWkjQSwCYWgxvy+dmD rjhZ9Q69HtlbU0vJp5mQ9o+lufFhIDvMGqLntLIUDrQc0XaQGsUe6KSI5YJaQOT+AgFe TNwr0ukS5weSR6KO60Gc7vIMUE/nla/JJufm0jGtL08xxXPlhP79HklTxo4LgbBaJok3 l5Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=v0WJukgTLOjialbbq4s4zJU7nr7whkAt/u15ZCMUhUo=; b=R0raFQvMFdfiRsXtvo8a66lFxrG0xvC6zqqg+r3AJ0pc0G5/NnxqsdWu1jV03p8XNi DJXXRPeDj8yj7x7jskg9jPLDMLj7/wWrkHj+QdS4tQJu9jLCaCkUmtC4V+EckhN1uaV0 M2PnIbL7C5ceBwDXfsaqMF7ADN/C8ttWubBq/jy9FNG3FtjHhALE+Hd6TWvVDpV2zWx5 J2gsPqPIui28am6v1/K/QrRaec5D4rZkreJpl2PuUv6OQ//ECR19yzwd6zAGlMilaARF xDbNuk0O97eMwFxNCB+9dY4r58Gbv7HVdlTJyyiGEQswU7sbTyRFFiWVREBQvKcR/wO8 xu/Q== X-Gm-Message-State: AO0yUKUKRuwaXqi1ROWGRq2fCrrwvdNo31Bo8j2oAJGJRO6UR/15En1J Dq+3lQZeV3vhFotLN3d8TCjLKN5a2Ck= X-Google-Smtp-Source: AK7set9cvohrNvDNb1dSqglamfuznSU3uibRwJBMIZL4AzGbkopfsJuWMdbP6zVlgCLgiMif7vnZtw== X-Received: by 2002:a5d:5982:0:b0:2bf:c05d:60bd with SMTP id n2-20020a5d5982000000b002bfc05d60bdmr2028919wri.55.1674693505537; Wed, 25 Jan 2023 16:38:25 -0800 (PST) Received: from beren.harmstone.com ([2a02:8010:64ea:0:8eb8:7eff:fe53:9d5f]) by smtp.gmail.com with ESMTPSA id t20-20020adfa2d4000000b002bdcce37d31sm6574836wra.99.2023.01.25.16.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 16:38:25 -0800 (PST) Sender: Mark Harmstone From: Mark Harmstone To: binutils@sourceware.org Cc: Mark Harmstone Subject: [PATCH 2/2] gas/testsuite: Add -gcodeview test for aarch64-w64-mingw32 Date: Thu, 26 Jan 2023 00:38:20 +0000 Message-Id: <20230126003820.28482-2-mark@harmstone.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126003820.28482-1-mark@harmstone.com> References: <20230126003820.28482-1-mark@harmstone.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,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 List-Id: This is a copy of the x86 gas -gcodeview test, with changes made for the differing instruction lengths between x86 and aarch64. --- gas/testsuite/gas/aarch64/codeview-lines | 9 + gas/testsuite/gas/aarch64/codeview.exp | 332 +++++++++++++++++++++++ gas/testsuite/gas/aarch64/codeview1.s | 7 + gas/testsuite/gas/aarch64/codeview2.s | 2 + 4 files changed, 350 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/codeview-lines create mode 100644 gas/testsuite/gas/aarch64/codeview.exp create mode 100644 gas/testsuite/gas/aarch64/codeview1.s create mode 100644 gas/testsuite/gas/aarch64/codeview2.s diff --git a/gas/testsuite/gas/aarch64/codeview-lines b/gas/testsuite/gas/aarch64/codeview-lines new file mode 100644 index 00000000000..241c01dc16f --- /dev/null +++ b/gas/testsuite/gas/aarch64/codeview-lines @@ -0,0 +1,9 @@ + +tmpdir/codeview-lines: file format binary + +Contents of section .data: + 0000 00000000 00000000 10000000 00000000 ................ + 0010 01000000 14000000 00000000 05000080 ................ + 0020 18000000 02000000 1c000000 04000000 ................ + 0030 01000080 08000000 02000080 00000000 ................ + 0040 01000000 14000000 0c000000 07000080 ................ diff --git a/gas/testsuite/gas/aarch64/codeview.exp b/gas/testsuite/gas/aarch64/codeview.exp new file mode 100644 index 00000000000..958bcdc835d --- /dev/null +++ b/gas/testsuite/gas/aarch64/codeview.exp @@ -0,0 +1,332 @@ +# Copyright (C) 2022-2023 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +if { ![istarget "aarch64-*-*"] } then { + return +} + +if { ![istarget "*-*-mingw*"] && ![istarget "*-*-pe*"] } then { + return +} + +proc read_subsection { fi } { + set data [read $fi 4] + binary scan $data i type + + set data [read $fi 4] + binary scan $data i len + + set data [read $fi $len] + + if { [expr $len % 4] != 0 } { + seek $fi [expr 4 - ($len % 4)] current + } + + return [list $type $data] +} + +proc check_file_checksums { chksums string_table } { + set off 0 + + # check first file + + set data [string range $chksums $off [expr $off + 3]] + incr off 4 + binary scan $data i string_off + + set filename [string range $string_table $string_off [expr [string first \000 $string_table $string_off] - 1]] + + if ![string match "*codeview1.s" $filename] { + fail "Incorrect filename for first source file" + } else { + pass "Correct filename for first source file" + } + + set data [string range $chksums $off $off] + incr off + binary scan $data c hash_length + + if { $hash_length != 16 } { + fail "Incorrect hash length" + } else { + pass "Correct hash length" + } + + set data [string range $chksums $off $off] + incr off + binary scan $data c hash_type + + if { $hash_type != 1 } { + fail "Incorrect hash type" + } else { + pass "Correct hash type" + } + + set data [string range $chksums $off [expr $off + $hash_length - 1]] + incr off $hash_length + binary scan $data H* hash + + if ![string equal $hash "e396a2450f45912c0818c2b779ff05df"] { + fail "Incorrect MD5 hash" + } else { + pass "Correct MD5 hash" + } + + # skip padding + if { [expr $off % 4] != 0 } { + incr off [expr 4 - ($off % 4)] + } + + # check second file + + set data [string range $chksums $off [expr $off + 3]] + incr off 4 + binary scan $data i string_off + + set filename [string range $string_table $string_off [expr [string first \000 $string_table $string_off] - 1]] + + if ![string match "*codeview2.s" $filename] { + fail "Incorrect filename for second source file" + } else { + pass "Correct filename for second source file" + } + + set data [string range $chksums $off $off] + incr off + binary scan $data c hash_length + + if { $hash_length != 16 } { + fail "Incorrect hash length" + } else { + pass "Correct hash length" + } + + set data [string range $chksums $off $off] + incr off + binary scan $data c hash_type + + if { $hash_type != 1 } { + fail "Incorrect hash type" + } else { + pass "Correct hash type" + } + + set data [string range $chksums $off [expr $off + $hash_length - 1]] + incr off $hash_length + binary scan $data H* hash + + if ![string equal $hash "0374189e155c0a8aaa09c4ffdc23ec11"] { + fail "Incorrect MD5 hash" + } else { + pass "Correct MD5 hash" + } +} + +proc check_lines { lines } { + global OBJDUMP + global srcdir + global subdir + + set fi [open tmpdir/codeview-lines w] + fconfigure $fi -translation binary + puts -nonewline $fi $lines + close $fi + + gas_host_run "$OBJDUMP -s --target=binary tmpdir/codeview-lines" ">& tmpdir/codeview-lines-text" + + set exp [file_contents "$srcdir/$subdir/codeview-lines"] + set got [file_contents "tmpdir/codeview-lines-text"] + + if [string equal $exp $got] { + pass "Correct lines info" + } else { + fail "Incorrect lines info" + } +} + +proc check_objname { sym } { + binary scan $sym s type + + if { $type != 0x1101 } { + fail "Symbol was not S_OBJNAME" + return + } else { + pass "Symbol was S_OBJNAME" + } + + binary scan [string range $sym 2 5] i signature + + if { $signature != 0 } { + fail "S_OBJNAME signature was not 0" + return + } else { + pass "S_OBJNAME signature was 0" + } + + set filename [string range $sym 6 [expr [string first \000 $sym 6] - 1]] + + if ![string match "*codeview1.o" $filename] { + fail "Incorrect object name in S_OBJNAME" + } else { + pass "Correct object name in S_OBJNAME" + } +} + +proc check_compile3 { sym } { + binary scan $sym s type + + if { $type != 0x113c } { + fail "Symbol was not S_COMPILE3" + return + } else { + pass "Symbol was S_COMPILE3" + } + + set data [string range $sym 6 7] + binary scan $data s machine + + if { $machine != 0xf6 } { + fail "Incorrect machine type in S_COMPILE3" + } else { + pass "Correct machine type in S_COMPILE3" + } + + set assembler_name [string range $sym 24 [expr [string first \000 $sym 24] - 1]] + + if ![string match "GNU AS *" $assembler_name] { + fail "Incorrect assembler name" + } else { + pass "Correct assembler name" + } +} + +proc check_symbols { symbols } { + set off 0 + + # check S_OBJNAME record + + set data [string range $symbols $off [expr $off + 1]] + incr off 2 + binary scan $data s sym_len + + set sym [string range $symbols $off [expr $off + $sym_len - 1]] + incr off $sym_len + + check_objname $sym + + # check S_COMPILE3 record + + set data [string range $symbols $off [expr $off + 1]] + incr off 2 + binary scan $data s sym_len + + set sym [string range $symbols $off [expr $off + $sym_len - 1]] + incr off $sym_len + + check_compile3 $sym +} + +gas_run codeview1.s "-gcodeview -I $srcdir/$subdir -o tmpdir/codeview1.o" ">&dump.out" + +if { [file size "dump.out"] != 0 } { + fail "Failed to assemble codeview1.s" + return +} else { + pass "Assembled codeview1.s" +} + +gas_host_run "$OBJCOPY --dump-section .debug\\\$S=tmpdir/codeview-debug tmpdir/codeview1.o" ">&dump.out" + +if { [file size "dump.out"] != 0 } { + fail "Failed to extract .debug\$S section from codeview1.o" + return +} else { + pass "Extracted .debug\$S section from codeview1.o" +} + +set fi [open tmpdir/codeview-debug] +fconfigure $fi -translation binary + +# check signature + +set data [read $fi 4] +binary scan $data i cv_sig + +if { $cv_sig != 4 } { + fail "Invalid CodeView signature" + close $fi + return +} else { + pass "Correct CodeView signature" +} + +# read string table (DEBUG_S_STRINGTABLE) + +set result [read_subsection $fi] + +if { [lindex $result 0] != 0xf3 } { + fail "Subsection was not string table" + close $fi + return +} else { + pass "Read string table" +} + +set string_table [lindex $result 1] + +# read file checksums (DEBUG_S_FILECHKSMS) + +set result [read_subsection $fi] + +if { [lindex $result 0] != 0xf4 } { + fail "Subsection was not file checksums" + close $fi + return +} else { + pass "Read file checksums" +} + +check_file_checksums [lindex $result 1] $string_table + +# read line info (DEBUG_S_LINES) + +set result [read_subsection $fi] + +if { [lindex $result 0] != 0xf2 } { + fail "Subsection was not line info" + close $fi + return +} else { + pass "Read line info" +} + +check_lines [lindex $result 1] + +# read CodeView symbols (DEBUG_S_SYMBOLS) + +set result [read_subsection $fi] + +if { [lindex $result 0] != 0xf1 } { + fail "Subsection was not symbols" + close $fi + return +} else { + pass "Read symbols" +} + +check_symbols [lindex $result 1] + +close $fi diff --git a/gas/testsuite/gas/aarch64/codeview1.s b/gas/testsuite/gas/aarch64/codeview1.s new file mode 100644 index 00000000000..15626c5c459 --- /dev/null +++ b/gas/testsuite/gas/aarch64/codeview1.s @@ -0,0 +1,7 @@ +.text + +.global main +main: + nop + .include "codeview2.s" + nop diff --git a/gas/testsuite/gas/aarch64/codeview2.s b/gas/testsuite/gas/aarch64/codeview2.s new file mode 100644 index 00000000000..c4e2dbcb132 --- /dev/null +++ b/gas/testsuite/gas/aarch64/codeview2.s @@ -0,0 +1,2 @@ +nop +nop -- 2.39.1