From patchwork Thu Nov 30 11:18:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Smith X-Patchwork-Id: 120137 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp531472qgn; Thu, 30 Nov 2017 03:18:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMY9X47slrWxgVoHdgkZQGQKLB2aXUMGkjl8qP3UcrJG0/A3LZlV6BglDq1IvjEL9Jwo5w+W X-Received: by 10.99.117.13 with SMTP id q13mr2041044pgc.231.1512040734193; Thu, 30 Nov 2017 03:18:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512040734; cv=none; d=google.com; s=arc-20160816; b=OvXGviLFxD2QLw9L0rJVDutcMd/p+VtP3hQrBYAWLhb+uvXE4iiYigc92TU1brICeT u2Rm281m+lxGgvLxTvKxI7gConmKQ3r6xJG3pEBKW8KrwLl5vlaSI1XwZeb7LRzScgmL BEigmbtIBAB/xergYgxe4+xJVXOV3ZeNBocEEP2a17htKJYO3jD9MRKygJ7KHo5S8CI5 KWDp72pmibJCgoyYyJJqgC6Ex729xeK4nmWu5vveE0gPQqQCsJfGBD2bzJLLQpyf940C DZrJ1L0SsnK9ut25c6Stwkj1zpOLxb+tKSjoku+umevV8Xeua5WJScMu226tygOc9DHN NIrQ== 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:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=1CpS0JSrmeUFDOp3YTMQAss/IGswHjUzB1WnHmWLHyg=; b=eUfyyPCqMa4O83uKD9krF/42as1o42gFJWt2Sul5tPRbkvIM2dZuLCI0xFZevw6u4e gyskLqQrSDGDFXLnbC7l3BeMaPkA6j+Fei7j5PK4A/yQYxta0oRIYgMNps8ShiWaUIqP DjeKLFuMYZXSmeWag2uMW2n9+zr3Cb2fEfIwwmeJaVW1xcOSaWyicSSHDYeILk0N8rJV VoaHqKzgzJDDiTrxo9/nYGbHY7t9fHCLCcy1TpgYDtk3RqbBLGp1d/+QJosGW3WlMsa4 u73gfjncdPmxMB/WsfHJHFplvuo8vJjiaLU6dTffPpuSfmM1joC2DxsLPtB2sntG5MjW T3VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=rKtN9LRY; spf=pass (google.com: domain of binutils-return-99611-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-99611-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 m61si2975881plb.136.2017.11.30.03.18.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Nov 2017 03:18:54 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-return-99611-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=rKtN9LRY; spf=pass (google.com: domain of binutils-return-99611-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-99611-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=Gvsl0LueezgzTjdGAX66e2blnhfOS HM3un1dkNiORYGmictL3yTbvGJlj1wYjVS+7nUyMTVmNIqnXHTu7kiJRC5BfRLEW 8cx5SCPmqoD7OFWesxG/FC//XqPoDHcFfASg1fnIDU6T4nVF8vhjfko7xQzveGk+ /D/HS/zAeGIzWg= 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=y7oWyIjxuXmsc37Rz6JFjw4E0fQ=; b=rKt N9LRYAhpfDMU+axG8nsZQofTpR22C59O3MF9deh1mH1CvlczDtjT1il02Rpd+riW /WWcRUDGfIfZzJ1aGzMKyh0EvgZgUJoNObCcK0zmsYT0rkQWN9/nZkMKy+kBzk/T CmCgoxFNqUadYWkrQ1zHTBKLoER0HzcRoGs7CBkg= Received: (qmail 58350 invoked by alias); 30 Nov 2017 11:18:40 -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 56349 invoked by uid 89); 30 Nov 2017 11:18:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=GOLD X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Nov 2017 11:18:37 +0000 Received: by mail-wr0-f174.google.com with SMTP id z34so6182688wrz.10 for ; Thu, 30 Nov 2017 03:18:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Te5SLuZfukjcOu8Q+uhl/vWc0JLjX6iMKAN89itlHKY=; b=M2xjdWvYmVhS9IymIowRAywb64lGUlKXGvhE67nYoavZksSHqZ79uJPbdjL0e0PtRE JkFz4tb9e4607YsvBJPPhqT2cYDsV0d9TWrdQblLzvwy+tpPk6/AjsgOSnjrNx/RkvDu flPYCIE8dVsE0s9ZYk1Wa64vMjfq3z+HvPJ3K/B5w0jlNTe2w8uZdQKyuinwzFMoZRpt urfDDUzx8rjJ6q2xFIu8GD4C4azbZIZBOjCeWzk3KAd05tyA4AWzXnWF/PGp/X9hzqcU RvjDAe/EiTfX9+vNO1tY1Q8AHOq1PS87aqBm/U1OXt6woQf4h0OanWqRxevL2xN+wLmJ X8Eg== X-Gm-Message-State: AJaThX5jSrfPnNUtuPl5ntp1GoZ5aMmDrVuzoGBroubwgeQCwT/Qc5WU iuUiUQACpprMNaH+uk/sdnDT0tvvwWhzvhEosL7mhGBqRdE= X-Received: by 10.223.170.150 with SMTP id h22mr1643817wrc.26.1512040714993; Thu, 30 Nov 2017 03:18:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.156.202 with HTTP; Thu, 30 Nov 2017 03:18:34 -0800 (PST) From: Peter Smith Date: Thu, 30 Nov 2017 11:18:34 +0000 Message-ID: Subject: [PATCH][GOLD] Fix PR0765 [2.27 Regression] gold internal error in fix_errata on aarch64-linux-gnu To: binutils@sourceware.org Hello, I've recently investigated https://sourceware.org/bugzilla/show_bug.cgi?id=20765 which is an internal fault in gold when the --fix-cortex-a53-843419 is applied. The bug is reported against 2.27 but still exists on trunk. The test case gitit is a very large program that uses two stub tables for the .text output section. The full details are in the PR, to summarise: - The internal fault is caused when there is more than one stub table and the addresses in the second stub table are dependent on the size of the first stub table. As the erratum stub addresses are only set once, an internal fault is triggered at relocation time when the inconsistency is detected. - The patch is to update the erratum stub addresses on each relaxation pass. After fixing the internal fault, I noticed that about 1/3 of the erratum stubs were being created and written to the file, but were being incorrectly skipped over by fix_errata_and_relocate_erratum_stubs(). This is a separate problem that, while more likely to hit large programs, could in theory hit smaller programs so I'll send a separate message with a fix for that. Peter diff --git a/gold/aarch64.cc b/gold/aarch64.cc index c9c1b33..74c411d 100644 --- a/gold/aarch64.cc +++ b/gold/aarch64.cc @@ -1031,6 +1031,18 @@ public: set_erratum_address(AArch64_address addr) { this->erratum_address_ = addr; } + // Later relaxation passes of may alter the recorded erratum and destination + // address. Given an up to date output section address of shidx_ in + // relobj_ we can derive the erratum_address and destination address. + void + update_erratum_address(AArch64_address output_section_addr) + { + const int BPI = AArch64_insn_utilities::BYTES_PER_INSN; + AArch64_address updated_addr = output_section_addr + this->sh_offset_; + this->set_erratum_address(updated_addr); + this->set_destination_address(updated_addr + BPI); + } + // Comparator used to group Erratum_stubs in a set by (obj, shndx, // sh_offset). We do not include 'type' in the calculation, because there is // at most one stub type at (obj, shndx, sh_offset). @@ -2305,6 +2317,19 @@ AArch64_relobj::scan_errata( output_address = poris->address(); } + // Update the addresses in previously generated erratum stubs. Unlike when + // we scan relocations for stubs, if section addresses have changed due to + // other relaxations we are unlikely to scan the same erratum instances + // again. + The_stub_table* stub_table = this->stub_table(shndx); + if (stub_table) + { + std::pair + ipair(stub_table->find_erratum_stubs_for_input_section(this, shndx)); + for (Erratum_stub_set_iter p = ipair.first; p != ipair.second; ++p) + (*p)->update_erratum_address(output_address); + } + section_size_type input_view_size = 0; const unsigned char* input_view = this->section_contents(shndx, &input_view_size, false);