From patchwork Sat Oct 22 12:53:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Lapshin X-Patchwork-Id: 7884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1191830wrr; Sat, 22 Oct 2022 05:54:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6I/wZYOxTKbr6bKbqJ9/3iEOJmw3/ZSuXzoxOuTss3qS7W1ioQJOlwAx4MeTeUGJFd/bFb X-Received: by 2002:a05:6402:1d4a:b0:45c:98a9:7ba3 with SMTP id dz10-20020a0564021d4a00b0045c98a97ba3mr22321319edb.418.1666443250182; Sat, 22 Oct 2022 05:54:10 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h12-20020a056402280c00b0046190898e26si510234ede.533.2022.10.22.05.54.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 05:54:10 -0700 (PDT) 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=@sourceware.org header.s=default header.b=oT0BHDdV; arc=fail (signature failed); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 200BC3858C62 for ; Sat, 22 Oct 2022 12:54:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 200BC3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666443249; bh=WKyMH9Gl81PXxRYYFZZWE/sipUoAbi+XuR4p4T/0bqs=; h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=oT0BHDdVHqsl+A87r9JjsK5bvOTz9+k27VLWOOmdv+6IPeIe+ho7i+Lws336wfO6i PRiBE8bMPKkDBkYzYbALwdIGmN9fCjXtcsJv7fut3dNkeWVKx4SHA9toEU5O3vGovd x8NrsbowsmsfgiNmsXxPxjT9fYgob9HQDkDIDCu4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2135.outbound.protection.outlook.com [40.107.117.135]) by sourceware.org (Postfix) with ESMTPS id 7D3183858D1E for ; Sat, 22 Oct 2022 12:53:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D3183858D1E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BmzopRWXhFIa0QLh4Vx/MsrVftxHIXfxerg25HcWkHIe+yQNqNT0bFp/d6uEKcn4R7ePYOETPC+ioJ2uUV2h6Nb4oaoEvzXC+rHAcoj1GqkYjUhfdwC0XxwuSh0EFaXPyUHp7MkTLIIDJJwUPxHHJCNlHTIIfXuXnMmT3fmv8FqNPHD/O4Evg8z1jf6031zO9LkvXS4raZQjOzjyvAxUd1GhNtoodToomaZHLn0i5Kj5jbUh7Gxl6eSiSHhn2M0GGeYC1JVXbeqR6w0XZUO62FeQqAbtmjMo91VDep2/Zl+c1V8SdNFEwtz5rvXkE8UCkwsCsNL0DwkPy1fzQ2yP/A== 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=WKyMH9Gl81PXxRYYFZZWE/sipUoAbi+XuR4p4T/0bqs=; b=AQdJY9VvCqohs9OQtJMBUMH7AnxxTrILPlksrasPt8PMSLRciat9qHmFiArv/Or91bbFaZO1eJJk8JrPUyOahZzrgkh0CL3VGrOxCNaiR/xBX6wdKYvSaGogyd6g1G4hJGAL85PIUg4rPR/jX7nvprs1zKv4SueaOj1O43E+s3rzdYToVhGGNuJsDpEvYmIwtJoJBtnCHy2SDyHo9bZYId8bz3TwQseDc6GmeEyjtuK00wEuNgySrgGs16b7kHezPAkslhikPK+YDmMDmGuYLOuE72KSWsdFDPqa2xASVhdESoL40ri601v5KICRA0JaZZEGPDY9nRhsrAzmL9K6Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=espressif.com; dmarc=pass action=none header.from=espressif.com; dkim=pass header.d=espressif.com; arc=none Received: from TYZPR04MB5736.apcprd04.prod.outlook.com (2603:1096:400:1fa::7) by SEYPR04MB5908.apcprd04.prod.outlook.com (2603:1096:101:68::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.35; Sat, 22 Oct 2022 12:53:54 +0000 Received: from TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::e64d:5c85:a83c:5898]) by TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::e64d:5c85:a83c:5898%4]) with mapi id 15.20.5723.032; Sat, 22 Oct 2022 12:53:54 +0000 To: "binutils@sourceware.org" Subject: [PATCH 1/5] bfd: xtensa: move common code from ld and gas Thread-Topic: [PATCH 1/5] bfd: xtensa: move common code from ld and gas Thread-Index: AQHY5hVX62/elafWOEG/L275K1abuw== Date: Sat, 22 Oct 2022 12:53:54 +0000 Message-ID: <7e53b7980f2b3b74d2250bc87f5db94b1d888a2d.camel@espressif.com> References: <94fd668465b77e94f3c000982c694e7da8f828f1.camel@espressif.com> In-Reply-To: <94fd668465b77e94f3c000982c694e7da8f828f1.camel@espressif.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYZPR04MB5736:EE_|SEYPR04MB5908:EE_ x-ms-office365-filtering-correlation-id: a5e1773e-a224-4992-1813-08dab42c7a08 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gvya13aeniUEm9wfUN8XL7VFSTVZWuY7LX0XTAQfa/aG/riKbYLXbGS8cJMOIFAB6EiLCMg0qc/u1OgxEWYIVNVZ4erzZWNwLffcP7FbJ4Ega7RITa85KNe9WeYbZoeBJmYpUd/7+jfo5dYNIcKYCooonAe6pjaAhW8zH/ST3CunFCL94e4uRfSsmXHccVgrFq1p/Sc7Up6qhdLFWMYpvxC1EMqkG82K+F/HwS/7+EjhP22TahzqZX3M020d31LSV3tOuTDg1bP92RviLlqUKF2NPtJDtl5Efbm5H0zfaCfXfmrK7bGoFTztYrYqDG2iR0/GBXFxgrp9Y4JAygPIADByjbOX4xNUuhhnHs/mUuKIFKO9v9Gt9+Uo1TJCTE7jHq1Ucl2XsUCntQzyEJgwjk1LCWRPcpX9pH1DNydFW21d1Q1nYZBgcxLLpyxQFZi/fbnbure29herXV/TQKWyOuzz346+IZeT6dwM0VuIeFb05IVX+YlXmd6l46wGPPs0oB+f9Cgga0X2II8K7KRa/q4RbHGoR0PRg6s/OfOhTA2j2cEWJ1J0SwKH5TmgP/rABe0oF1JRvaHKIPN4HEj+lM1QvlH9cx3CqOfSx4lsRTgk3wfchQQcVH4639RxJX1bXz/6dgeILnSWLmxFOS1dwOHdIbRhld+A1vPiuAl1L58DHN8v00iXBlA9FqqtpgCnlOnZiuoZAjUogjLbKfjrJPL+mKM/zrqTgw5oBl1Ly6xh8zOPar/S4e8lpbDxD/JH2Q6gikjnDhVchK7u4n6Qmw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB5736.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(376002)(39840400004)(136003)(366004)(396003)(346002)(451199015)(91956017)(2906002)(107886003)(8676002)(38070700005)(5660300002)(76116006)(4326008)(66476007)(66446008)(6506007)(122000001)(54906003)(66556008)(6916009)(38100700002)(64756008)(66946007)(86362001)(83380400001)(6512007)(8936002)(26005)(36756003)(41300700001)(186003)(2616005)(6486002)(44832011)(478600001)(316002)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?Pm6q9AX0syWGXFkGopoxrxwqrFXd?= =?utf-8?q?5I+I+B9p5qrD3guf3XYPc7y4FKaOUED61r38MNufBCKq7YtN9DpgQDOAq1qI0HmTH?= =?utf-8?q?6Wx9XWX/r7/feq7dYPG/VrzG5myXwse+QSw7zafsUHo5+LFeXxS2WPqn3HBSATuqE?= =?utf-8?q?9cwOMH3EEVpEzHeOeqqwPLdpwHXGVnl/XP9zkpqcc8YrD1vYgzYkavhRM1DNmjdlb?= =?utf-8?q?ghQ1G1DMPRezU1uq+pXf1AVU+8kgQFiBcPlQUoDJSrrkBUZcXdSV+5gPcdESxgR2L?= =?utf-8?q?UhPBt+alA6tvIXpdevIzbvjxSEUOOMp350rqM5tIeHUP368QgRoQlEh7TDDbrQtL9?= =?utf-8?q?ME6SrU58juJ77BjrrqgUGzNX6dUUcjolc3HN3LcHT8oAeBeC0qg4tJ6WT0gIGWGGU?= =?utf-8?q?n5855RAm34Lu7d1JlXPR7aIwuNH0Jl62QH6636sCyNfwkGyhr+CqCrSW2YYRMRL5O?= =?utf-8?q?yNRHta/WItWBtbgojGlncqzwMjmXjhEwOYMIG0wT7jvcF5iUI/9vX1xfofeTW0B48?= =?utf-8?q?gtpUykFzKjwGOqJEdhE9Nax8ydb/9WGhxE3RZpd2j5W/7H/UuuwDxD3M9irXDh3RB?= =?utf-8?q?ofP8KfcemgsqPM2hvs3RwqYuuL0drB2MLQYwDd63P0amP05Dv7aeacRE9bVOYXIRS?= =?utf-8?q?ky+SEWYFviDuiYaBhp2UUpBZkCIlugjOwaEWOYnYTRBtiP79APICuuJBf/0atQOz2?= =?utf-8?q?VHaMUVAbKHQySN57mOZ3VaADr0d1raQ92oS8WCefnbkVppW6rFCFXcZxhT3OMpeyq?= =?utf-8?q?gmB9cR32JiFE8EiBlKzgEh1drzRoxPzoLsf67CxR5xhQUAqA9fDvgtqoeZKt0zyI+?= =?utf-8?q?no2tPKeukUJVm6QtL3Uldw7VzAlWBFL259HAluhJx5Np+c+ZFc756yjpd/0av0S1+?= =?utf-8?q?t86FLH40glVfOzke23iFgWl8xgZWQjRVaCRNSpZaEx2YLk3N+vuLY5tYzY+qpZDUs?= =?utf-8?q?9MN0HdxtpIt581UsmvJQwxTqjeLNlscQaK7iI4Hx+GTIzUo4jflnTDS8ytmQdSknv?= =?utf-8?q?eEUgObQtsPRlSR5zswYKDqZQm21t55PMOoCs4fdmxbWCmxARVqMxZD9NxllWi4vhZ?= =?utf-8?q?f1krZ/K6ont6620Keia9cKgvZzoJeBvj4hKfF4wbLygDSskz1AtmGNcpg/JGZtfyX?= =?utf-8?q?lZLTPiftvMt9g58z1KCql1RcVdKLE+nbDAA8fo3y21HkgDP/QerMXhDj6OoT1ZUYk?= =?utf-8?q?stNDeEQ+AsCtbGMObWzxRsp6SzLOIWXCJgEyXGQf8GDOZTWUGVr3ggY8Gyvj0dOCS?= =?utf-8?q?RpXGmejwhSa1R1L8vBcN5TfCc0bsDs5r/GPDStOuMpN0LDatP9tJbzHLKLiQN5cbf?= =?utf-8?q?/D33ahQwygq47cm6UphiAmNDzoCQfWoW0a/74VujQSZWPQHlKqwhuNf+SVUqHYjbr?= =?utf-8?q?QL9xlP3AFc62nz6KWPf9lhQZT+9xKjet6zBoYyxOWCC8x7MtMWNCVP+FGd3CZFEyS?= =?utf-8?q?JuIlneIkNyFZuJQD5dXpEEFhzV/aRE4IfRp/D/ejCkX0Ok8ZptJmnxoJmYa9jMtni?= =?utf-8?q?IxrDIvCXWWPdLqc+ptH9GrGmhsapZwLPbG/Gy9gxXXjmpIl8PECPtCo=3D?= Content-ID: <5EA4C2632911854986176229B22A9E02@apcprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: espressif.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB5736.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5e1773e-a224-4992-1813-08dab42c7a08 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2022 12:53:54.4945 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5faf27fd-3557-4294-9545-8ea74a409f39 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: D+xT/0LRAwNgS1oCITQXPrY6A7J9NRtiYVnYf5I2G5p1buGBm9z4HzbedGeiXLfrWbIwdbU6pWgu8wO3CfSPQeTgKDaq1sHCdy4nYtB9UP8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB5908 X-Spam-Status: No, score=-13.1 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: , X-Patchwork-Original-From: Alexey Lapshin via Binutils From: Alexey Lapshin Reply-To: Alexey Lapshin Cc: Anton Maklakov , Alexey Gerenkov , Ivan Grokhotkov 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?1747392397689935755?= X-GMAIL-MSGID: =?utf-8?q?1747392397689935755?= Just refactor the common code to easy maintain. --- bfd/elf32-xtensa.c | 108 +++++++++++++++++++++++++++++++++++ gas/config/tc-xtensa.c | 7 +-- include/elf/xtensa.h | 18 ++++++ ld/emultempl/xtensaelf.em | 116 ++++++-------------------------------- 4 files changed, 144 insertions(+), 105 deletions(-) + einfo (_("%P: %pB: warning: Xtensa incompatible use of the Extended L32R option (%d != %d)\n"), + abfd, entries->use_absolute_literals, XSHAL_USE_ABSOLUTE_LITERALS); + } } @@ -423,6 +340,7 @@ check_xtensa_info (bfd *abfd, asection *info_sec) static void elf_xtensa_before_allocation (void) { + xtensa_info_entries xtensa_info; asection *info_sec, *first_info_sec; bfd *first_bfd; bool is_big_endian = XCHAL_HAVE_BE; @@ -477,7 +395,8 @@ elf_xtensa_before_allocation (void) /* Unpack the .xtensa.info section and check it against the current Xtensa configuration. */ - check_xtensa_info (f->the_bfd, info_sec); + if (read_xtensa_info (f->the_bfd, info_sec, &xtensa_info)) + check_xtensa_info (f->the_bfd, &xtensa_info); /* Do not include this copy of .xtensa.info in the output. */ info_sec->size = 0; @@ -504,8 +423,7 @@ elf_xtensa_before_allocation (void) info_sec->flags |= SEC_IN_MEMORY; data = xmalloc (100); - sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n", - XSHAL_USE_ABSOLUTE_LITERALS, xtensa_abi_choice ()); + fill_xtensa_info (&data); xtensa_info_size = strlen (data) + 1; /* Add enough null terminators to pad to a word boundary. */ -- 2.34.1 diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index cb658483ca6..77ff4d63381 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -11495,6 +11495,114 @@ xtensa_callback_required_dependence (bfd *abfd, return ok; } +static void +xtensa_info_set_entry (char *key, int value, xtensa_info_entries *entries) +{ + if (! strcmp (key, "ABI")) + { + entries->abi = value; + } + else if (! strcmp (key, "USE_ABSOLUTE_LITERALS")) + { + entries->use_absolute_literals = value; + } +} + +static bool +xtensa_info_parse (char *data, xtensa_info_entries *entries) +{ + char *d, *key; + + d = data; + while (*d) + { + key = d; + d = strchr (d, '='); + if (! d) + goto error; + + /* Overwrite the equal sign. */ + *d++ = 0; + + /* Check if this is a quoted string or a number. */ + if (*d == '"') + { + /* No string values are currently checked by LD; + just skip over the quotes. */ + d++; + d = strchr (d, '"'); + if (! d) + goto error; + /* Skip the trailing quote. */ + d++; + } + else if( *d >= '0' && *d <= '9' ) + { + int value = strtoul (d, &d, 0); + xtensa_info_set_entry (key, value, entries); + } + else + goto error; + + if (*d++ != '\n') + goto error; + } + + return true; + +error: + return false; +} + +bool +read_xtensa_info (bfd *abfd, asection *info_sec, xtensa_info_entries *entries) +{ + bool ret = false; + char *data = (char *) bfd_malloc (info_sec->size); + + /* initialize values */ + entries->abi = XSHAL_ABI; + entries->use_absolute_literals = XSHAL_USE_ABSOLUTE_LITERALS; + + if (! bfd_get_section_contents (abfd, info_sec, data, 0, info_sec- >size)) + { + fprintf (stderr, _("%pB: cannot read contents of section %pA\n"), + abfd, info_sec); + goto exit; + } + + if (! (info_sec->size > 24 + && info_sec->size >= 24 + bfd_get_32 (abfd, data + 4) + && bfd_get_32 (abfd, data + 0) == XTINFO_NAMESZ + && bfd_get_32 (abfd, data + 8) == XTINFO_TYPE + && strcmp (data + 12, XTINFO_NAME) == 0 + && xtensa_info_parse (data + 12 + XTINFO_NAMESZ, entries) + ) + ) + { + fprintf (stderr, + _("%pB: warning: cannot parse .xtensa.info section\n"), + abfd); + goto exit; + } + + ret = true; + +exit: + free (data); + return ret; +} + +void +fill_xtensa_info (char **data) +{ + sprintf (*data, + "USE_ABSOLUTE_LITERALS=%d\n" + "ABI=%d\n", + XSHAL_USE_ABSOLUTE_LITERALS, + xtensa_abi_choice ()); +} + /* The default literal sections should always be marked as "code" (i.e., SHF_EXECINSTR). This is particularly important for the Linux kernel module loader so that the literals are not placed after the text. */ diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index 3e3deb5dd36..df6a3cec8a1 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -8982,10 +8982,6 @@ is_local_forward_loop (const TInsn *insn, fragS *fragP) return false; } -#define XTINFO_NAME "Xtensa_Info" -#define XTINFO_NAMESZ 12 -#define XTINFO_TYPE 1 - static void xtensa_add_config_info (void) { @@ -8997,8 +8993,7 @@ xtensa_add_config_info (void) bfd_set_section_flags (info_sec, SEC_HAS_CONTENTS | SEC_READONLY); data = XNEWVEC (char, 100); - sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n", - XSHAL_USE_ABSOLUTE_LITERALS, xtensa_abi_choice ()); + fill_xtensa_info (&data); sz = strlen (data) + 1; /* Add enough null terminators to pad to a word boundary. */ diff --git a/include/elf/xtensa.h b/include/elf/xtensa.h index 542821b0dc9..6d916f8fd64 100644 --- a/include/elf/xtensa.h +++ b/include/elf/xtensa.h @@ -138,6 +138,18 @@ typedef struct property_table_entry_t flagword flags; } property_table_entry; +/* .xtensa.info section related definitions */ + +#define XTINFO_NAME "Xtensa_Info" +#define XTINFO_NAMESZ sizeof(XTINFO_NAME) +#define XTINFO_TYPE 1 + +typedef struct xtensa_info_entries_t +{ + int abi; + int use_absolute_literals; +} xtensa_info_entries; + /* Flags in the property tables to specify whether blocks of memory are literals, instructions, data, or unreachable. For instructions, blocks that begin loop targets and branch targets are designated. @@ -228,6 +240,12 @@ xtensa_compute_fill_extra_space (property_table_entry *entry); extern int xtensa_abi_choice (void); +extern void +fill_xtensa_info (char **data); + +extern bool +read_xtensa_info (bfd *abfd, asection *info_sec, xtensa_info_entries *entries); + #ifdef __cplusplus } #endif diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em index 9d527daea95..ed2945b850d 100644 --- a/ld/emultempl/xtensaelf.em +++ b/ld/emultempl/xtensaelf.em @@ -312,108 +312,25 @@ elf_xtensa_after_open (void) } -static bool -xt_config_info_unpack_and_check (char *data, - bool *pmismatch, - char **pmsg) +static void +check_xtensa_info (bfd *abfd, xtensa_info_entries *entries) { - char *d, *key; - int num; - - *pmismatch = false; - - d = data; - while (*d) + /* Check ABI */ + if (elf32xtensa_abi == XTHAL_ABI_UNDEFINED) { - key = d; - d = strchr (d, '='); - if (! d) - goto error; - - /* Overwrite the equal sign. */ - *d++ = 0; - - /* Check if this is a quoted string or a number. */ - if (*d == '"') - { - /* No string values are currently checked by LD; - just skip over the quotes. */ - d++; - d = strchr (d, '"'); - if (! d) - goto error; - /* Overwrite the trailing quote. */ - *d++ = 0; - } - else - { - if (*d == 0) - goto error; - num = strtoul (d, &d, 0); - - if (! strcmp (key, "ABI")) - { - if (elf32xtensa_abi == XTHAL_ABI_UNDEFINED) - { - elf32xtensa_abi = num; - } - else if (num != elf32xtensa_abi) - { - *pmismatch = true; - *pmsg = "ABI does not match"; - } - } - else if (! strcmp (key, "USE_ABSOLUTE_LITERALS")) - { - if (num != XSHAL_USE_ABSOLUTE_LITERALS) - { - *pmismatch = true; - *pmsg = "incompatible use of the Extended L32R option"; - } - } - } - - if (*d++ != '\n') - goto error; + elf32xtensa_abi = entries->abi; } - - return true; - - error: - return false; -} - - -#define XTINFO_NAME "Xtensa_Info" -#define XTINFO_NAMESZ 12 -#define XTINFO_TYPE 1 - -static void -check_xtensa_info (bfd *abfd, asection *info_sec) -{ - char *data, *errmsg = ""; - bool mismatch; - - data = xmalloc (info_sec->size); - if (! bfd_get_section_contents (abfd, info_sec, data, 0, info_sec- >size)) - einfo (_("%F%P: %pB: cannot read contents of section %pA\n"), abfd, info_sec); - - if (info_sec->size > 24 - && info_sec->size >= 24 + bfd_get_32 (abfd, data + 4) - && bfd_get_32 (abfd, data + 0) == XTINFO_NAMESZ - && bfd_get_32 (abfd, data + 8) == XTINFO_TYPE - && strcmp (data + 12, XTINFO_NAME) == 0 - && xt_config_info_unpack_and_check (data + 12 + XTINFO_NAMESZ, - &mismatch, &errmsg)) + else if (entries->abi != elf32xtensa_abi) { - if (mismatch) - einfo (_("%P: %pB: warning: incompatible Xtensa configuration (%s)\n"), - abfd, errmsg); + einfo (_("%P: %pB: warning: Xtensa ABI does not match\n"), abfd); } - else - einfo (_("%P: %pB: warning: cannot parse .xtensa.info section\n"), abfd); - free (data); + /* Check USE_ABSOLUTE_LITERALS */ + if (entries->use_absolute_literals != XSHAL_USE_ABSOLUTE_LITERALS) + {