From patchwork Mon Oct 24 07:44:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 78867 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp2436176qge; Mon, 24 Oct 2016 00:45:09 -0700 (PDT) X-Received: by 10.98.153.204 with SMTP id t73mr26039012pfk.144.1477295109190; Mon, 24 Oct 2016 00:45:09 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q1si14074932pfc.271.2016.10.24.00.45.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Oct 2016 00:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-94207-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; spf=pass (google.com: domain of binutils-return-94207-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-94207-patch=linaro.org@sourceware.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:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=SX+zHY8xZFmaNtEdU0reb3U2KQKCf IVBXzQWzoHOGaAITx61lix7lLhGkUyJkFZbUJJoL2PCwWc+kdps++Av7M3fh4CY8 hj4pwR1v3AM3veVGEiml4hpDICbxyWK2AK9sed/gj1Auag1kM142gEnT4XIVSSos Qbh7ggG81waBKo= 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:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=x1km/b0F/pCKkjGznDNDtKyoFe4=; b=GKi Hs/s3vAmlvmOYKYI5uX5lcNMpTP2ZrYNh/n6W1BKdt8bzTesB5NqVsCNRIqspRuU awdvleMpoFRlKFFxHVu5OfI9syqTbbGCMs6GVOIlIp6pBgxqguaI7BHSWKhJPWea +Go9/TGwcC85MhiZiZ3ATqtY7XuJix4cpdE0SMm8= Received: (qmail 55280 invoked by alias); 24 Oct 2016 07:44:52 -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 53964 invoked by uid 89); 24 Oct 2016 07:44:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=*abfd, abfd, bfd_link_info, *ibfd X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Oct 2016 07:44:40 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D29882B; Mon, 24 Oct 2016 00:44:37 -0700 (PDT) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40A923F21A; Mon, 24 Oct 2016 00:44:37 -0700 (PDT) To: Nick Clifton , Alan Modra , binutils@sourceware.org From: Thomas Preudhomme Subject: [PATCH, binutils/ld] Initialize input statement created in add_archive_member Message-ID: <89d23099-259b-0843-25f6-7457758b7081@foss.arm.com> Date: Mon, 24 Oct 2016 08:44:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-IsSubscribed: yes add_archive_member creates an input statement structure but fails to initialize the type of the structure accordingly. I noticed this while trying to browse all input statement structures in the statement, file and input file list in ld as some structures were skipped due to the wrong type. This patch adds the necessary initialization and adds an assert in plugin_object_p which assumes input statement and was receiving one of the badly initialized structures. ChangeLog entry is as follows: *** ld/ChangeLog *** 2016-10-21 Thomas Preud'homme * ldmain.c (add_archive_element): Initialize input->header.type. * plugin.c (plugin_maybe_claim): Assert the statement is an input statement. Testsuite shows no regression on arm-none-eabi and armeb-none-eabi. Is this ok for master branch? Best regards, Thomas diff --git a/ld/ldmain.c b/ld/ldmain.c index 29ef77f4f02f43e4c167c2e4794d1e60d81394d2..2f15ba72a9c6aeddf40761c3ff6d5a4b13428bf5 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -800,6 +800,7 @@ add_archive_element (struct bfd_link_info *info, input = (lang_input_statement_type *) xcalloc (1, sizeof (lang_input_statement_type)); + input->header.type = lang_input_statement_enum; input->filename = abfd->filename; input->local_sym_name = abfd->filename; input->the_bfd = abfd; diff --git a/ld/plugin.c b/ld/plugin.c index 80d22e222d097cbc8004759bf71ac7fa678f5461..804294049af6daa4b9449c8abbd4d25277c07e6c 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -1195,6 +1195,7 @@ plugin_object_p (bfd *ibfd) void plugin_maybe_claim (lang_input_statement_type *entry) { + ASSERT (entry->header.type == lang_input_statement_enum); if (plugin_object_p (entry->the_bfd)) { bfd *abfd = entry->the_bfd->plugin_dummy_bfd;