From patchwork Tue Jul 27 14:51:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 60145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id AA855B6EF3 for ; Thu, 29 Jul 2010 00:10:05 +1000 (EST) Received: (qmail 9031 invoked by alias); 28 Jul 2010 14:09:58 -0000 Received: (qmail 9017 invoked by uid 22791); 28 Jul 2010 14:09:56 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_12_24, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (213.235.205.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Jul 2010 14:09:47 +0000 Received: from basil.firstfloor.org (p5B3C94DA.dip0.t-ipconnect.de [91.60.148.218]) by one.firstfloor.org (Postfix) with ESMTP id 6ADD4A0000C for ; Wed, 28 Jul 2010 16:09:44 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id BC321B250F; Tue, 27 Jul 2010 16:51:29 +0200 (CEST) Date: Tue, 27 Jul 2010 16:51:29 +0200 From: Andi Kleen To: gcc-patches@gcc.gnu.org Subject: [PATCH] LTO: Handle merged option sections Message-ID: <20100727145128.GA32142@basil.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org LTO: Handle merged option sections This closes one small hole in the merged section "ld -r" handling. The options section does not have a suffix and can be merged. Fix the option reader to loop over all copies of the options. Passed a bootstrap and full test suite run on x86_64-linux Ok to commit? 2010-07-27 Andi Kleen * lto-opts.c (lto_file_read_options): Add loop over all inputs. Index: gcc/lto-opts.c =================================================================== --- gcc/lto-opts.c (revision 162566) +++ gcc/lto-opts.c (working copy) @@ -349,8 +349,8 @@ void lto_read_file_options (struct lto_file_decl_data *file_data) { - size_t len; - const char *data; + size_t len, l, skip; + const char *data, *p; const struct lto_simple_header *header; int32_t opts_offset; struct lto_input_block ib; @@ -358,14 +358,30 @@ data = lto_get_section_data (file_data, LTO_section_opts, NULL, &len); if (!data) return; - header = (const struct lto_simple_header *) data; - opts_offset = sizeof (*header); - lto_check_version (header->lto_header.major_version, - header->lto_header.minor_version); + /* Option could be multiple sections merged (through ld -r) + Keep reading all options. This is ok right now because + the options just get mashed together anyways. + This will have to be done differently once lto-opts knows + how to associate options with different files. */ + l = len; + p = data; + do + { + header = (const struct lto_simple_header *) p; + opts_offset = sizeof (*header); - LTO_INIT_INPUT_BLOCK (ib, data + opts_offset, 0, header->main_size); - input_options (&ib); + lto_check_version (header->lto_header.major_version, + header->lto_header.minor_version); + + LTO_INIT_INPUT_BLOCK (ib, p + opts_offset, 0, header->main_size); + input_options (&ib); + + skip = header->main_size + opts_offset; + l -= skip; + p += skip; + } + while (l > 0); lto_free_section_data (file_data, LTO_section_opts, 0, data, len); }