From patchwork Tue Jul 2 09:04:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 168298 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3981929ilk; Tue, 2 Jul 2019 02:04:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4k4d1G5kEb3YNZAehbvPR91wbYkbQjp4CwM1vGuig1uGbItWSdnoJFnYnwVSRMgfQ/MQP X-Received: by 2002:a63:1950:: with SMTP id 16mr29438095pgz.312.1562058291719; Tue, 02 Jul 2019 02:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562058291; cv=none; d=google.com; s=arc-20160816; b=YTetDKz5KTJAplYgokBiSi5cyXTtQJNt50Fvkvdlls5UOPkhe0Nb51PY/pvfqPY8XB f3a7i5jTm55z7A5kAFu9F87BHV1sdzhPRJcL8WmbbeTgVuwv34ImvkxkwQt4StNIx6Ac /tPQDglsQa0rqJTafMQymulWMROM8hsRbD9rSbnrfeUvR/71ppr22c5hiXlMqF1eKcRb lPL8EsblSwfKf51wUdgy4Q+9p6I6KlJYjGLuzYU5QiUHGH9BAT5G0BirKhpvs29KE0yn dCfG4RFUWawFk2k4R5PEZdID1ClWX/X4QwZKiBRwmdTFnQN3rh8YL47uCgxtQWdgL2cr 3tjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:dkim-signature :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=LYUsTZIpTYhv/A9g1XxcEijb+X6ma4APOyMstr9nvmQ=; b=nzR0mPLAUwHhqnC0o0ITIttcVVjNE8QEo1HagtLHRxvF/kSANtrxQTwfUGDYDw5NLw 9zl+OJtoIFtAgwafJhpLbydfnXm9NdjXgJ+9NgP0NpaDsUKDwlrUVsLfl3YtVGp6H12T M3GqpjpXXdGs996L1GPacPgyLgixEJUQw16LKrWH7te7FDoTexD5qhyBYOPWvAwG2qU+ UY062+k5YhR5IH+i9dF361pGp+/konIpBewvN2QfiDQ+Dw/fdlTMC813fPq8Nvj1OgDy Ly9vBhXlDdfbaqmtyfX+/IQ/sQdKxv7VbmlWsoLcb6ldWqHkO3qhAPBt7eS3FmKBHs92 bRQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=dgeMs3cD; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=zdf1XWzq; spf=pass (google.com: domain of binutils-return-106224-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="binutils-return-106224-patch=linaro.org@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id k11si1711691pjs.73.2019.07.02.02.04.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2019 02:04:51 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-106224-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=dgeMs3cD; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=zdf1XWzq; spf=pass (google.com: domain of binutils-return-106224-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="binutils-return-106224-patch=linaro.org@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=MtohP4wDYA/y7A+2xV3/vPfA+FSwD PPbNHa+EWhMF4GRCiSLXSoILpIY/mzVQC1EYGJisnuNyT+qyB+Phfd19+DS4Iq0A 5kzDXAXOtJ7dldsTdFQL1IP6QV9zjKNu73GHvWoRpo8maJnuHVDqwC7pGNOR3xRT T/Ld/XahCFbkhY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=JocCxFMg1ylw43Yz4DqKSDCZ3xw=; b=dge Ms3cD3g8GyGsmUr2RBj+mSO7Q2zw3lE6kdvSE3uk+b3wzLZnE+5TcRCukXBjXleS op/Gv4y05tHoLP8M8Oyzk/g9SPtc0xJqJDnvsqzjFeeInH+TErOD7iKhKmcjqS2c zvGcnZjyXuch2mofOdjWCqUUgIjRdJNbhDKGc1wo= Received: (qmail 7285 invoked by alias); 2 Jul 2019 09:04:39 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 7277 invoked by uid 89); 2 Jul 2019 09:04:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-HELO:sk:mail-yb X-HELO: mail-yb1-f182.google.com Received: from mail-yb1-f182.google.com (HELO mail-yb1-f182.google.com) (209.85.219.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Jul 2019 09:04:37 +0000 Received: by mail-yb1-f182.google.com with SMTP id j199so1052372ybg.5 for ; Tue, 02 Jul 2019 02:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:from:date:message-id:subject:to; bh=C+v/tNZJ2jeiBdnHZ7q4colO8HroAxHpDz8lTDoW7eY=; b=zdf1XWzq+KWMAF6gZ1kkdcrU1mIXUailp76J+07MHFHn+1/Vcmyk2Sz5Tvv9fj94cs GHO2sYwHcFhgwWYeegl28IwGpeOvKiUkj+TrroWIbsAgyhS7GHaq5GqesG4+zh7RSZbW TIZOtwfzyvFGHbnkE0Q+MGvZ54KAnY/344KqiIkS5QDqu7XOFTghZ4ilq2p5Un5tTBiZ j+StmbHJ+J3v/ekU/xTy+Xwzp4tBZXyVs3vOiLp/EHFy7N2M/dRbh9gt43RcSFyr7g2k 88QlwX6jWzOope/Gmo3/zr4OLH7As2UXme2SmEMxmqNKwnJ3bxcx/fDWxMqwY/JuWMV7 U0OQ== MIME-Version: 1.0 From: Christophe Lyon Date: Tue, 2 Jul 2019 11:04:24 +0200 Message-ID: Subject: [PATCH] PR ld/24709 [arm] linker crash and assertion failure with CMSE To: binutils X-IsSubscribed: yes Hi, As discussed in the PR, we do not support the case where CMSE stubs are inserted too far from their destination. This would require an intermediate long-branch stub, which is tricky in this context. Instead of crashing, this patch emit an error message and exits. I will send a GCC testsuite patch separately to avoid placing the CMSE stubs too far. OK? Christophe 2019-07-02 Christophe Lyon * bfd/elf32-arm.c (CMSE_STUB_NAME): New define. (elf32_arm_get_stub_entry): Do not try to emit long-branch stubs for CMSE stubs. (arm_dedicated_stub_output_section_name): Use CMSE_STUB_NAME. commit a1c05db5efe1b430ad465199bbe53fa3cf7cd434 Author: Christophe Lyon Date: Tue Jul 2 08:57:06 2019 +0000 PR ld/24709 [arm] linker crash and assertion failure with CMSE As discussed in the PR, we do not support the case where CMSE stubs are inserted too far from their destination. This would require an intermediate long-branch stub, which is tricky in this context. Instead of crashing, this patch emit an error message and exits. 2019-07-02 Christophe Lyon * bfd/elf32-arm.c (CMSE_STUB_NAME): New define. (elf32_arm_get_stub_entry): Do not try to emit long-branch stubs for CMSE stubs. (arm_dedicated_stub_output_section_name): Use CMSE_STUB_NAME. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 52fd48f..275b603 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2300,6 +2300,8 @@ typedef unsigned short int insn16; #define CMSE_PREFIX "__acle_se_" +#define CMSE_STUB_NAME ".gnu.sgstubs" + /* The name of the dynamic interpreter. This is put in the .interp section. */ #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" @@ -4583,6 +4585,27 @@ elf32_arm_get_stub_entry (const asection *input_section, if ((input_section->flags & SEC_CODE) == 0) return NULL; + /* If the input section is the CMSE stubs one and it needs a long + branch stub to reach it's final destination, give up with an + error message: this is not supported. See PR ld/24709. */ + if (!strncmp (input_section->name, CMSE_STUB_NAME, strlen(CMSE_STUB_NAME))) + { + bfd *output_bfd = htab->obfd; + asection *out_sec = bfd_get_section_by_name (output_bfd, CMSE_STUB_NAME); + + _bfd_error_handler (_("ERROR: CMSE stub (%s section) too far " + "(%#" PRIx64 ") from destination (%#" PRIx64 ")"), + CMSE_STUB_NAME, + (uint64_t)out_sec->output_section->vma + + out_sec->output_offset, + (uint64_t)sym_sec->output_section->vma + + sym_sec->output_offset + + h->root.root.u.def.value); + /* Exit, rather than leave incompletely processed + relocations. */ + xexit(1); + } + /* If this input section is part of a group of sections sharing one stub section, then use the id of the first section in the group. Stub names need to include a section id, as there may well be @@ -4676,7 +4699,7 @@ arm_dedicated_stub_output_section_name (enum elf32_arm_stub_type stub_type) switch (stub_type) { case arm_stub_cmse_branch_thumb_only: - return ".gnu.sgstubs"; + return CMSE_STUB_NAME; default: BFD_ASSERT (!arm_dedicated_stub_output_section_required (stub_type));