From patchwork Thu Feb 23 11:11:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 60908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp253746wrd; Thu, 23 Feb 2023 03:11:49 -0800 (PST) X-Google-Smtp-Source: AK7set/iTsTKZENbLGkwUXM4z18Dt03C+6fZZg5ayNhuLcg5FFHwkYR/1qmFnx3+0tLwJ1oZTDPC X-Received: by 2002:a05:6402:5156:b0:4ad:7205:8427 with SMTP id n22-20020a056402515600b004ad72058427mr11284995edd.27.1677150709375; Thu, 23 Feb 2023 03:11:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677150709; cv=pass; d=google.com; s=arc-20160816; b=FVsLzTrGFxuI9mm0ch+jbnPLLd5dDghMRK02BOOKjErh4Vi8PRvD2acXOI6dw0TpH5 PCa2UI92Mp6dQBo2jKNjb5dQ7un9XPzYM4S7B3LeOu29JxmOOYLy6MPovHEqDBOvJ9tg TtnesqcHe0lEmR2a9iHuyzQWTG+ne/3UzpdRvISQ4CMXvAGyeRCV+LiRLBSOEYbcCsIQ xK7cpcismZtdOiBrculYnpZttJBDaIJrJcEMKy/IPcetzS9//DVgZJJQog+1GxvIc430 fg2k9fmyD6xX5IdC76kjuQ5t1G1wb7Zh2tWpMbScmH4WoJUBwNvpQLte8uUv4t3Wdyxt 1w6w== ARC-Message-Signature: i=2; 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:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dmarc-filter:delivered-to; bh=U5O9Y3jGZo4jEM2ZaYcqCGp5mXKRXbHhWZY7UEK3moY=; b=CYYd09fkuq5IqTwdQ+F7AuWKtfem3jQ/Cq8ZjYaAFwshNgD+IEBF+3Awrr17qeY+KG 5ZcUF45N8puCK9I3BsMc+U1UCgWMRNxBJtdKCsWpDIKmI9bc/AssO1foA8TpOw9Ma/UW CICtZEj09U0D0Pq2EmYGGI7KH63BxT8mjBE/TrcSSMIwlAB+CjIrXL/pdzruqXyhmxzb HdHB6wzuzkuX41F8BnkkRq2XCt8HtODhzeQQHB24WR71Cs7Hk+Yvkmzpncq/gjN6aEFK tX6M75bDIXyk/bIc6KLESzt7vjZSGQ8q3XDLz4Iv0o6WtQAe7hjw6+ffd9DZCj7GsnVH i2Ig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b="BgISSn/F"; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d1-20020a056402516100b004ad12c250a7si3653678ede.111.2023.02.23.03.11.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 03:11:49 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b="BgISSn/F"; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 67F5A385B514 for ; Thu, 23 Feb 2023 11:11:46 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2121.outbound.protection.outlook.com [40.107.255.121]) by sourceware.org (Postfix) with ESMTPS id C4C713858C5E for ; Thu, 23 Feb 2023 11:11:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4C713858C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cipunited.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cipunited.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X4agGhsMLxNIem+gsq5gVE73JT4XDwO0iu/JrK85WK9K8SlFR6i87d6u12DjHoPWfewIAPBHiKJAjSveIULX65jlvB595ygC6mSl00X95+e+H2HyhGXIglh/FGNzvlOSSxRTFnf0Y7IzY5lox8kJz0TvzIusuG9jhEPUPTK3SsG87gQ7ZAriplOu7F2b2/P74BgEG6FCx6wBwlkmLoN79FFq/TCbRGUYqu0xDTfjmsSIZYLT4CtBysk84M7Hu5th5gS7nU5N9h25aiMliYWnSNccS7tsQJIoygdXJcqEqvq6XMHnSDQFm8jDZUINuziU1H2EDSyeeYoo4oBpzEMCiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U5O9Y3jGZo4jEM2ZaYcqCGp5mXKRXbHhWZY7UEK3moY=; b=e/QIjcOBQoAsufdfmATpODrajs9gmwxfaUfrPIlNzHwTOTtmowUENKvbyFQ7z3wGH0KUzVWIhg23kv4JfcPIAlI5MRnAJPk9l9xtXwg38ulhD/SudiZm7NewbunkbYfXlEaECsKXs4e0Au17W/v1ZW7D7+sMVWbehvskWRii2ZV5fuYNfVEVEJ+gOnx8a6U5oW3oQ27+4rXmsRwjqdFxdVpxE38AsKFPi41RguIrOphFiACYsktX/W+9K8niNzOFzaEqu/9MR/P7sgGYdEjYRCEontngRAPHEu4KZ4NwlI756/fABLY+Y4bf+3xVojkoGRjSTxQ4XbNKGs02bhjcJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cipunited.com; dmarc=pass action=none header.from=cipunited.com; dkim=pass header.d=cipunited.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cipunited.onmicrosoft.com; s=selector1-cipunited-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U5O9Y3jGZo4jEM2ZaYcqCGp5mXKRXbHhWZY7UEK3moY=; b=BgISSn/FUIVcwCCnu16V+XsGgqW/MOUVMQM6BHg7vlWDNZDRaZ8u20VsZfaxQSrxTTgBUDWmJNSbiEvGEeLOSI/dpbCjRQ2divunYnDXaWSm56pMLwGr/vYXAtYh6b43e78k7HOGU4ifLem87w2z7sZK2LG8x6QLQr3vlxfZ3mc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cipunited.com; Received: from TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) by SI2PR04MB5703.apcprd04.prod.outlook.com (2603:1096:4:1be::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.19; Thu, 23 Feb 2023 11:11:32 +0000 Received: from TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::b2cb:a598:3a7e:367a]) by TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::b2cb:a598:3a7e:367a%2]) with mapi id 15.20.6134.021; Thu, 23 Feb 2023 11:11:31 +0000 From: YunQiang Su To: binutils@sourceware.org Cc: syq@debian.org, macro@orcam.me.uk, xry111@xry111.site, richard.sandiford@arm.com, jiaxun.yang@flygoat.com, YunQiang Su Subject: [PATCH] MIPS: support specify isa level when configure Date: Thu, 23 Feb 2023 19:11:15 +0800 Message-Id: <20230223111115.3752443-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210308043016.11511-2-yunqiang.su@cipunited.com> References: <20210308043016.11511-2-yunqiang.su@cipunited.com> X-ClientProxiedBy: TYBP286CA0019.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:ce::31) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|SI2PR04MB5703:EE_ X-MS-Office365-Filtering-Correlation-Id: 4af3ef35-ffa3-4222-64c0-08db158eb7ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R6NLIDXYl5KjVutpUVkk0PXd4qvgW1MY2KWXbKPpf/Nd+axzQe7QdTCexAAi2cH6nk2hl6327MpY+0lVxcaqTlsxPwVMj0Xjuaqb5B9RoL2Wslhw2HkfGDFycTngQo9cpSoCza6gxTysUoqR4ZAAkfmh6QtaBzpixXj5Vxch9xkMa3KehrkBsh+sSq0pxQuAr1I9zEgAtfSsHLUzqrgcTLMYfGLNGZOSQ6m6CJCHLxD8z5TrFPdXwiiHWC4OUln22XPEzVXBZGLaYMtnlCUv+vmzu2OzgrO0tSBJVwROYSw6PVXccV5UgL1o87247yyOKS97K3b627G4a3fNUrWSPVjHVZ5IymJ9w94F/3YttYO7ziwAj7RW1hzECCyJrh7zaLWXlWpNsNNrUrP+avKLzKbUiMpRmHOL/3qNFyE1SBwlmj678jjHMgaYV8Si5OJjBQC4y+l0gBXHfjQVkjnRI2Nt41fjcOxQsylKi74dsHlzVGOtVR8/f2GQYhWhpt62o5UHCYzIprNj/oHjiEnWhV6/5OgRfczcnNy5zQ84f1/KmSpTw3TMeSLhExTTm+wp2HNtOkLwe55S3XumHFdJNhWQOTSpw93JYFfRGGV8cC2nE3afXHdbIuo93AfvoHhCU27Y/r95lNojcREZ8Ud2lWb3fx9Wi80cT69z6j6TwOIf6vowUqE/1e053qpXBwSX X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB6117.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(39830400003)(396003)(366004)(136003)(346002)(376002)(451199018)(5660300002)(8936002)(30864003)(41300700001)(107886003)(2906002)(2616005)(6486002)(52116002)(6506007)(316002)(478600001)(26005)(6666004)(1076003)(66476007)(66556008)(66946007)(8676002)(6512007)(186003)(6916009)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M/ImDkgUF22l5zBBPjznAjNxAX8cBRMNckqFn4F9gTZaRDUD3+eHXL/+Sbg5bmhIejuVmrohClSjQqJmF98eZYMBb5PHSHyQ59RS39Sj8bJ5vhzvyNcDbCzNN4M1nqNrp5uG1ZSDdt7/HYEtiUpd/dKyCSlrYirN8ENdsvITkAmJ6uqWTSMx75yDqKiTvKcgytBvCGN3NZlHmpl35koW5ZkY4EPyBFxcrS/NHs7e47fAOePDvL1e4rH5mFMyV5hGtV6qPTgWPc0iyLR+K7Ms4P7GFDrakVfPl3WTG+G+INbsgGL/b9qXOyFiYFnCAOfSJzulypVUj8exLLJI3I6dm3/C32lkAsMhXobs13G6VEPfBwFAXb+9D7usb/RVyoomTRVWzBdjuUDtFUNfRuN4vki3f3/v2uYd0G04a4CYHvwA88SSmXvnoGN/uGQJgsdpRikDheIRjXc0HtOFLSGsUt9/vhmWulaVjHHMQa7TFWBM+Ax9qy2fYDn2/V8/ZkYHo5SVXJoRo+p0HeOIjMZyV9NmV+iC4ANjvgEQ55HwsVX9cR/2jTUpTGqbRMnucR0QfJI/pN+v6k3RfXErz2PDzL0SfFjVb/rMaUBKEckAI2bmmFcNoJfhuIyT7j7Ahtt/T1HDfEBA1/6ImzOPDZQDAqGJQ3YXhrEDnWiD3W7OFCJkbovWZmRZz/KrZ/uGIQ3lcpZNzYWXApZ0K/SgjB6EwTHmarScxwCYPZlwiLKq51pO0CgowXigbxfC69hlbsXnWyena38GUdFC72EMVf8piTjq/mo8K+lXvEnslH71wkt6XiTPZZG+ukvyyfsDDziQN4q3yooDEKPugVzjla2z7TUE7dqhTrH2DHK1V1ciq6YbRCl4LCwsjYXvA9ICYUNyHmKx0MaJ0qJMoesfAtvOA38f4adHwiTf+go1WvPO9GdeOXlR5PkWQ8/KU2iB3DZVE3lXeft5GKaYK8FSP7cpz2xQikKPpQYa3uqdQJ3EJHGuhTmqV3KHcJ6Nzi01CHdfVD9vhRZl+xD4xQod91C8w7siMLtoTSmYe7DqnWt2pv7XaaJW8ulMEmI6yIRsiQp7NEaN/wQyuEteJi73h8eIGNf7hZO2MKtJk+6FNL373j26PJQDNAUsqAKrAIy5dp4w1cq4EzExxrbmuNh9n0n3z0hXSIVyVdOi7GICHN+nawdH4jGeZLQxC5Co1qTJslxoMLiqXB0aI+z17s8fl2I9GqodKbwOdsC2CWf14otE3dHn2CGMwdM/ocvk6E3w9ZYhiCI22CKYTCCKx9v2UzjJcdckNuKTlLB2bSV6xccKx+8zRWUtocnQC/7AEDVdsswuk2YIjxZlNGazBg8Vmb5Zu8GBxB0bwjusk7JGVQwF6MNMEech+Eo7KqQS64A1TWb6YIzIn34juFF6RTIic0iyNKUZkpzip93NqY6O6znyD3qrkLz5d0VA1mpFLAo0pwCncOFVBLfHlQES5PHbjbjNpWyMpVkiRJ+QVJO9Hv96gGG32F7Rm6TS5Py0yOVkI49WnNMGdlkxmh9IxQkiwmB8qPGAQEXfFwteK7wq1PdSzJ2czQxfHwcfgpKATM/5GYP5VQDh+JXxuZGZ/6YTNu0asQ== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4af3ef35-ffa3-4222-64c0-08db158eb7ab X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 11:11:31.7797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e31cf5b5-ee69-4d5f-9c69-edeeda2458c0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PybR0x4Tgnr5cVokmajqgtX5Vvvlyg3gV0VoWT91u+GDNh3W8bTpVLaE3jRumTcu9GeN2SUrTtZSRBzTFF2Qtki8ZbUgRu/v3yRAcog24No= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5703 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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?1758619982292295269?= X-GMAIL-MSGID: =?utf-8?q?1758619982292295269?= PR 25494. 1. Add mipsisa[32,64][,rN] support. the output of gas and ld will fellow this isa level. > ld -r -b binary xx.dat -o xx.o > as -march=from-abi xx.s 2. Support --with-arch=isa_level build option. If this option is used, the default isa_level for gas and ld will change. --- bfd/Makefile.in | 1 + bfd/config.bfd | 70 ++++++++++++++++++- bfd/configure | 14 ++++ bfd/configure.ac | 11 +++ bfd/elfxx-mips.c | 61 +++++++++++++++- .../binutils-all/mips/mips-note-2-n32.d | 1 + gas/config/tc-mips.c | 70 +++++++++++++++++-- gas/configure | 20 +++++- gas/configure.ac | 18 ++++- gold/configure.tgt | 14 ++++ ld/configure.tgt | 12 +++- 11 files changed, 279 insertions(+), 13 deletions(-) diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 82aa96f30e5..7b7b262d64e 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -332,6 +332,7 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEBUGDIR = @DEBUGDIR@ +DEFAULT_ARCH = @DEFAULT_ARCH@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ diff --git a/bfd/config.bfd b/bfd/config.bfd index 0b0f7d50602..cea93016105 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -227,6 +227,62 @@ z8k*) targ_archs=bfd_z8k_arch ;; *) targ_archs=bfd_${targ_cpu}_arch ;; esac +# Build option --with-arch. Only MIPS supports it now. +case "${targ}" in + mips*) + case "${DEFAULT_ARCH}" in + "") + case "${targ}" in + mipsisa64r6*) + DEFAULT_ARCH=mips64r6 + ;; + mipsisa64r5*) + DEFAULT_ARCH=mips64r5 + ;; + mipsisa64r3*) + DEFAULT_ARCH=mips64r3 + ;; + mipsisa64r2*) + DEFAULT_ARCH=mips64r2 + ;; + mipsisa64*) + DEFAULT_ARCH=mips64 + ;; + mipsisa32r6*) + DEFAULT_ARCH=mips32r6 + ;; + mipsisa32r5*) + DEFAULT_ARCH=mips32r5 + ;; + mipsisa32r3*) + DEFAULT_ARCH=mips32r3 + ;; + mipsisa32r2*) + DEFAULT_ARCH=mips32r2 + ;; + mipsisa32*) + DEFAULT_ARCH=mips32 + ;; + *) + ;; + esac + ;; + mips1 | mips2 | mips32 | mips32r2 | mips32r3 | mips32r5 | mips32r6 | \ + mips3 | mips4 | mips5 | mips64 | mips64r2 | mips64r3 | mips64r5 | mips64r6) + ;; + *) + echo "The arch name doesn't exits: ${DEFAULT_ARCH}" >&2 + exit -1 + ;; + esac + ;; + *) + if test x"${DEFAULT_ARCH}" != x""; then + echo "The value of option --with-arch is ignored for this arch: ${DEFAULT_ARCH}" >&2 + fi + DEFAULT_ARCH= + ;; +esac # WHEN ADDING ENTRIES TO THIS MATRIX: # Make sure that the left side always has two dashes. Otherwise you @@ -941,11 +997,21 @@ case "${targ}" in targ_defvec=mips_elf32_be_vec targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec" ;; - mips64*el-*-linux*) + mips*64*el-*-linux*-gnuabi64) + targ_defvec=mips_elf64_trad_le_vec + targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec" + want64=true + ;; + mips*64*-*-linux*-gnuabi64) + targ_defvec=mips_elf64_trad_be_vec + targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec" + want64=true + ;; + mips*64*el-*-linux*) targ_defvec=mips_elf32_ntrad_le_vec targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec" ;; - mips64*-*-linux*) + mips*64*-*-linux*) targ_defvec=mips_elf32_ntrad_be_vec targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec" ;; diff --git a/bfd/configure b/bfd/configure index 41d280ef461..a92d2d2251d 100755 --- a/bfd/configure +++ b/bfd/configure @@ -695,6 +695,7 @@ WARN_CFLAGS REPORT_BUGS_TEXI REPORT_BUGS_TO PKGVERSION +DEFAULT_ARCH DEBUGDIR ENABLE_BFD_64_BIT_FALSE ENABLE_BFD_64_BIT_TRUE @@ -12033,6 +12034,15 @@ fi +DEFAULT_ARCH= + +# Check whether --with-arch was given. +if test "${with_arch+set}" = set; then : + withval=$with_arch; DEFAULT_ARCH="${withval}" +fi + + + # Check whether --with-pkgversion was given. @@ -13775,6 +13785,10 @@ do fi done +if test -n "$DEFAULT_ARCH"; then + TDEFINES="$TDEFINES -DDEFAULT_ARCH=\\\"${DEFAULT_ARCH}\\\"" +fi + # This processing still needs to be done if we're to decide properly whether # 64-bit support needs to be compiled in. Currently, it will be included if diff --git a/bfd/configure.ac b/bfd/configure.ac index f044616f4d9..570a5e8bb7d 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -168,6 +168,13 @@ AC_ARG_WITH(separate-debug-dir, [DEBUGDIR="${withval}"]) AC_SUBST(DEBUGDIR) +DEFAULT_ARCH= +AC_ARG_WITH(arch, + AS_HELP_STRING([--with-arch=ARCH], + [Set the default arch for bfd [[default=]]]), +[DEFAULT_ARCH="${withval}"]) +AC_SUBST(DEFAULT_ARCH) + ACX_PKGVERSION([GNU Binutils]) ACX_BUGURL([https://sourceware.org/bugzilla/]) @@ -341,6 +348,10 @@ do TDEFINES="$TDEFINES $targ_cflags" fi done + +if test -n "$DEFAULT_ARCH"; then + TDEFINES="$TDEFINES -DDEFAULT_ARCH=\\\"${DEFAULT_ARCH}\\\"" +fi AC_SUBST(TDEFINES) # This processing still needs to be done if we're to decide properly whether diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index e9fb61ff9e7..338e7fdd0d6 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -47,6 +47,15 @@ #include "hashtab.h" +/* A table describing all ISA and its 32bit and 64bit version for best matching */ +struct mips_eflags_32_64 +{ + const char *name; + flagword e_mips_arch; + flagword e_mips_arch32; + flagword e_mips_arch64; +}; + /* Types of TLS GOT entry. */ enum mips_got_tls_type { GOT_TLS_NONE, @@ -1306,6 +1315,28 @@ bfd_get_micromips_32 (const bfd *abfd, const bfd_byte *ptr) #define TP_OFFSET 0x7000 #define DTP_OFFSET 0x8000 +/* A table describing all ISA and its 32bit and 64bit version for best matching */ +__attribute__ ((unused)) +static const struct mips_eflags_32_64 mips_eflags_32_64_table[] = +{ + { "mips1", E_MIPS_ARCH_1, E_MIPS_ARCH_1, E_MIPS_ARCH_3}, + { "mips2", E_MIPS_ARCH_2, E_MIPS_ARCH_2, E_MIPS_ARCH_3}, + { "mips3", E_MIPS_ARCH_3, E_MIPS_ARCH_2, E_MIPS_ARCH_3}, + { "mips4", E_MIPS_ARCH_3, E_MIPS_ARCH_2, E_MIPS_ARCH_4}, + { "mips5", E_MIPS_ARCH_5, E_MIPS_ARCH_2, E_MIPS_ARCH_5}, + { "mips32", E_MIPS_ARCH_32, E_MIPS_ARCH_32, E_MIPS_ARCH_64}, + { "mips32r2", E_MIPS_ARCH_32R2, E_MIPS_ARCH_32R2, E_MIPS_ARCH_64R2}, + { "mips32r3", E_MIPS_ARCH_32R2, E_MIPS_ARCH_32R2, E_MIPS_ARCH_64R2}, + { "mips32r5", E_MIPS_ARCH_32R2, E_MIPS_ARCH_32R2, E_MIPS_ARCH_64R2}, + { "mips32r6", E_MIPS_ARCH_32R6, E_MIPS_ARCH_32R6, E_MIPS_ARCH_64R6}, + { "mips64", E_MIPS_ARCH_64, E_MIPS_ARCH_32, E_MIPS_ARCH_64}, + { "mips64r2", E_MIPS_ARCH_64R2, E_MIPS_ARCH_32R2, E_MIPS_ARCH_64R2}, + { "mips64r3", E_MIPS_ARCH_64R2, E_MIPS_ARCH_32R2, E_MIPS_ARCH_64R2}, + { "mips64r5", E_MIPS_ARCH_64R2, E_MIPS_ARCH_32R2, E_MIPS_ARCH_64R2}, + { "mips64r6", E_MIPS_ARCH_64R6, E_MIPS_ARCH_32R6, E_MIPS_ARCH_64R6}, + { NULL, 0, 0, 0 } +}; + static bfd_vma dtprel_base (struct bfd_link_info *info) { @@ -12283,6 +12314,30 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, } +/* Get the E_MIPA_ARCH_?? value for the DEFAULT_ARCH + The value of bits can be 32/64 or 0 (guess from DEFAULT_ARCH) + */ +static flagword mips_get_default_arch_eflags(int bits) +{ +#ifdef DEFAULT_ARCH + int i; + + for (i = 0; mips_eflags_32_64_table[i].name; i++) + if (strcasecmp (mips_eflags_32_64_table[i].name, DEFAULT_ARCH) != 0) + continue; + else if (bits == 32) + return mips_eflags_32_64_table[i].e_mips_arch32; + else if (bits == 64) + return mips_eflags_32_64_table[i].e_mips_arch64; + else if (bits == 0) + return mips_eflags_32_64_table[i].e_mips_arch; +#endif + + if (bits == 64) + return E_MIPS_ARCH_3; + return E_MIPS_ARCH_1; +} + /* Set ABFD's EF_MIPS_ARCH and EF_MIPS_MACH flags. */ static void @@ -12294,9 +12349,11 @@ mips_set_isa_flags (bfd *abfd) { default: if (ABI_N32_P (abfd) || ABI_64_P (abfd)) - val = E_MIPS_ARCH_3; + val = mips_get_default_arch_eflags(64); + else if (ABI_O32_P (abfd)) + val = mips_get_default_arch_eflags(32); else - val = E_MIPS_ARCH_1; + val = mips_get_default_arch_eflags(0); break; case bfd_mach_mips3000: diff --git a/binutils/testsuite/binutils-all/mips/mips-note-2-n32.d b/binutils/testsuite/binutils-all/mips/mips-note-2-n32.d index c2a581858ed..5e24e7a115e 100644 --- a/binutils/testsuite/binutils-all/mips/mips-note-2-n32.d +++ b/binutils/testsuite/binutils-all/mips/mips-note-2-n32.d @@ -1,4 +1,5 @@ #PROG: objcopy +#as: -n32 #readelf: --notes --wide #objcopy: --merge-notes #name: MIPS merge notes section (n32) diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index e911aaa904a..c906471eb92 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -1422,6 +1422,15 @@ static int relaxed_micromips_16bit_branch_length (fragS *, asection *, int); static int relaxed_micromips_32bit_branch_length (fragS *, asection *, int); static void file_mips_check_options (void); +/* A table describing all ISA and its 32bit and 64bit version for best matching */ + +struct mips_isa_32_64 +{ + int isa; + int isa_32; + int isa_64; +}; + /* Table and functions used to map between CPU/ISA names, and ISA levels, and CPU numbers. */ @@ -1439,6 +1448,7 @@ struct mips_cpu_info static const struct mips_cpu_info *mips_parse_cpu (const char *, const char *); static const struct mips_cpu_info *mips_cpu_info_from_isa (int); static const struct mips_cpu_info *mips_cpu_info_from_arch (int); +static int mips_cpu_isa_32_64(int isa, int bits); /* Command-line options. */ const char *md_shortopts = "O::g::G:"; @@ -19979,6 +19989,28 @@ s_mips_mask (int reg_type) } } + +/* A table describing all ISA and its 32bit and 64bit version for best matching */ +static const struct mips_isa_32_64 mips_isa_32_64_table[] = +{ + { ISA_MIPS1, ISA_MIPS1, ISA_MIPS3 }, + { ISA_MIPS2, ISA_MIPS2, ISA_MIPS3 }, + { ISA_MIPS3, ISA_MIPS2, ISA_MIPS3 }, + { ISA_MIPS4, ISA_MIPS2, ISA_MIPS4 }, + { ISA_MIPS5, ISA_MIPS2, ISA_MIPS5 }, + { ISA_MIPS32, ISA_MIPS32, ISA_MIPS64 }, + { ISA_MIPS32R2, ISA_MIPS32R2, ISA_MIPS64R2 }, + { ISA_MIPS32R3, ISA_MIPS32R3, ISA_MIPS64R3 }, + { ISA_MIPS32R5, ISA_MIPS32R5, ISA_MIPS64R5 }, + { ISA_MIPS32R6, ISA_MIPS32R6, ISA_MIPS64R6 }, + { ISA_MIPS64, ISA_MIPS32, ISA_MIPS64 }, + { ISA_MIPS64R2, ISA_MIPS32R2, ISA_MIPS64R2 }, + { ISA_MIPS64R3, ISA_MIPS32R3, ISA_MIPS64R3 }, + { ISA_MIPS64R5, ISA_MIPS32R5, ISA_MIPS64R5 }, + { ISA_MIPS64R6, ISA_MIPS32R6, ISA_MIPS64R6 }, + { 0, 0, 0 } +}; + /* A table describing all the processors gas knows about. Names are matched in the order listed. @@ -20223,6 +20255,9 @@ static const struct mips_cpu_info * mips_parse_cpu (const char *option, const char *cpu_string) { const struct mips_cpu_info *p; + const struct mips_cpu_info *default_cpu; + int default_isa32 = ISA_MIPS1; + int default_isa64 = ISA_MIPS3; /* 'from-abi' selects the most compatible architecture for the given ABI: MIPS I for 32-bit ABIs and MIPS III for 64-bit ABIs. For the @@ -20236,19 +20271,26 @@ mips_parse_cpu (const char *option, const char *cpu_string) 'mips64', just as we did in the days before 'from-abi'. */ if (strcasecmp (cpu_string, "from-abi") == 0) { + for (default_cpu = mips_cpu_info_table; default_cpu->name != 0; default_cpu++) + if (mips_matching_cpu_name_p (default_cpu->name, MIPS_CPU_STRING_DEFAULT)) + { + default_isa32 = mips_cpu_isa_32_64 (default_cpu->isa, 32); + default_isa64 = mips_cpu_isa_32_64 (default_cpu->isa, 64); + break; + } if (ABI_NEEDS_32BIT_REGS (mips_abi)) - return mips_cpu_info_from_isa (ISA_MIPS1); + return mips_cpu_info_from_isa (default_isa32); if (ABI_NEEDS_64BIT_REGS (mips_abi)) - return mips_cpu_info_from_isa (ISA_MIPS3); + return mips_cpu_info_from_isa (default_isa64); if (file_mips_opts.gp >= 0) return mips_cpu_info_from_isa (file_mips_opts.gp == 32 - ? ISA_MIPS1 : ISA_MIPS3); + ? default_isa32 : default_isa64); return mips_cpu_info_from_isa (MIPS_DEFAULT_64BIT - ? ISA_MIPS3 - : ISA_MIPS1); + ? default_isa64 + : default_isa32); } /* 'default' has traditionally been a no-op. Probably not very useful. */ @@ -20263,6 +20305,24 @@ mips_parse_cpu (const char *option, const char *cpu_string) return 0; } +/* Return the best matching 32bit/64bit ISA of a ISA, according the table + mips_isa_32_64_table */ +static int +mips_cpu_isa_32_64(int isa, int bits) +{ + int i; + + for (i = 0; mips_isa_32_64_table[i].isa != 0; i++) + if (isa != mips_isa_32_64_table[i].isa) + continue; + else if (bits == 32) + return mips_isa_32_64_table[i].isa_32; + else if (bits == 64) + return mips_isa_32_64_table[i].isa_64; + + return 0; +} + /* Return the canonical processor information for ISA (a member of the ISA_MIPS* enumeration). */ diff --git a/gas/configure b/gas/configure index b56836998ef..11b0a56bbd4 100755 --- a/gas/configure +++ b/gas/configure @@ -12201,6 +12201,21 @@ _ACEOF as_fn_error $? "$target_cpu isn't a supported MIPS CPU name" "$LINENO" 5 ;; esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-arch" >&5 +$as_echo_n "checking for default configuration of --with-arch... " >&6; } + if test "x${with_arch}" != x; then + case ${with_arch} in + mips1 | mips2 | mips32 | mips32r2 | mips32r3 | mips32r5 | mips32r6 | \ + mips3 | mips4 | mips5 | mips64 | mips64r2 | mips64r3 | mips64r5 | mips64r6) + mips_cpu=${with_arch} + ;; + *) + as_fn_error $? "This kind of arch name does *NOT* exist!" "$LINENO" 5 + ;; + esac + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_arch" >&5 +$as_echo "$with_arch" >&6; } # See whether it's appropriate to set E_MIPS_ABI_O32 for o32 # binaries. It's a GNU extension that some OSes don't understand. case ${target} in @@ -12223,7 +12238,10 @@ _ACEOF esac # Decide which ABI to target by default. case ${target} in - mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ + mips*64*-linux-gnuabi64) + mips_default_abi=N64_ABI + ;; + mips*64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*) mips_default_abi=N32_ABI ;; diff --git a/gas/configure.ac b/gas/configure.ac index 6a68fd7c4e6..a126a3fda5d 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -370,6 +370,19 @@ changequote([,])dnl AC_MSG_ERROR($target_cpu isn't a supported MIPS CPU name) ;; esac + AC_MSG_CHECKING(for default configuration of --with-arch) + if test "x${with_arch}" != x; then + case ${with_arch} in + mips1 | mips2 | mips32 | mips32r2 | mips32r3 | mips32r5 | mips32r6 | \ + mips3 | mips4 | mips5 | mips64 | mips64r2 | mips64r3 | mips64r5 | mips64r6) + mips_cpu=${with_arch} + ;; + *) + AC_MSG_ERROR(This kind of arch name does *NOT* exist!) + ;; + esac + fi + AC_MSG_RESULT($with_arch) # See whether it's appropriate to set E_MIPS_ABI_O32 for o32 # binaries. It's a GNU extension that some OSes don't understand. case ${target} in @@ -392,7 +405,10 @@ changequote([,])dnl esac # Decide which ABI to target by default. case ${target} in - mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ + mips*64*-linux-gnuabi64) + mips_default_abi=N64_ABI + ;; + mips*64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*) mips_default_abi=N32_ABI ;; diff --git a/gold/configure.tgt b/gold/configure.tgt index 4b54e08d27f..ef47ce079f1 100644 --- a/gold/configure.tgt +++ b/gold/configure.tgt @@ -153,6 +153,13 @@ aarch64*-*) targ_big_endian=false targ_extra_big_endian=true ;; +mips*64*el*-*-*|mips*64*le*-*-*) + targ_obj=mips + targ_machine=EM_MIPS_RS3_LE + targ_size=64 + targ_big_endian=false + targ_extra_big_endian=true + ;; mips*el*-*-*|mips*le*-*-*) targ_obj=mips targ_machine=EM_MIPS_RS3_LE @@ -160,6 +167,13 @@ mips*el*-*-*|mips*le*-*-*) targ_big_endian=false targ_extra_big_endian=true ;; +mips*64*-*-*) + targ_obj=mips + targ_machine=EM_MIPS + targ_size=64 + targ_big_endian=true + targ_extra_big_endian=false + ;; mips*-*-*) targ_obj=mips targ_machine=EM_MIPS diff --git a/ld/configure.tgt b/ld/configure.tgt index efd43095844..5ccaca37f16 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -577,11 +577,19 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks ;; mips*-*-windiss) targ_emul=elf32mipswindiss ;; -mips64*el-*-linux-*) targ_emul=elf32ltsmipn32 +mips*64*el-*-linux-gnuabi64) targ_emul=elf64ltsmip + targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip" + targ_extra_libpath=$targ_extra_emuls + ;; +mips*64*el-*-linux-*) targ_emul=elf32ltsmipn32 targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip" targ_extra_libpath=$targ_extra_emuls ;; -mips64*-*-linux-*) targ_emul=elf32btsmipn32 +mips*64*-*-linux-gnuabi64) targ_emul=elf64btsmip + targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip" + targ_extra_libpath=$targ_extra_emuls + ;; +mips*64*-*-linux-*) targ_emul=elf32btsmipn32 targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip" targ_extra_libpath=$targ_extra_emuls ;;