From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21759 invoked by alias); 24 May 2011 14:59:00 -0000 Received: (qmail 21746 invoked by uid 22791); 24 May 2011 14:58:59 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_RG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 May 2011 14:58:44 +0000 Received: from kpbe19.cbf.corp.google.com (kpbe19.cbf.corp.google.com [172.25.105.83]) by smtp-out.google.com with ESMTP id p4OEwiOG030228 for ; Tue, 24 May 2011 07:58:44 -0700 Received: from pxi6 (pxi6.prod.google.com [10.243.27.6]) by kpbe19.cbf.corp.google.com with ESMTP id p4OEwg9I024605 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 24 May 2011 07:58:42 -0700 Received: by pxi6 with SMTP id 6so4133253pxi.31 for ; Tue, 24 May 2011 07:58:42 -0700 (PDT) Received: by 10.143.63.10 with SMTP id q10mr1107819wfk.291.1306249122230; Tue, 24 May 2011 07:58:42 -0700 (PDT) Received: from coign.google.com ([67.218.109.241]) by mx.google.com with ESMTPS id o3sm5052344pbt.61.2011.05.24.07.58.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 May 2011 07:58:41 -0700 (PDT) From: Ian Lance Taylor To: Cary Coutant Cc: Binutils Subject: Re: [gold patch] Incremental 15/18: Add --incremental-base option. References: Date: Tue, 24 May 2011 14:59:00 -0000 In-Reply-To: (Cary Coutant's message of "Mon, 25 Apr 2011 13:33:30 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00332.txt.bz2 Cary Coutant writes: > * gold.cc (queue_initial_tasks): Pass incremental base filename > to Output_file::open_base_file; don't print error message. > * incremental-dump.cc (main): Adjust call to > Output_file::open_for_modification. > * incremental-dump.cc (main): Likewise. > * incremental.cc (Incremental_inputs::report_command_line): > Ignore --incremental-base option when comparing command lines. > * options.h (class General_options): Add --incremental-base. > * output.cc (Output_file::Output_file): > (Output_file::open_base_file): Add base_name and writable parameters; > copy base file to new file; print error message here. > (Output_file::map_no_anonymous): Add writable parameter; adjust all > callers. > * output.h (Output_file::open_for_modification): Rename to... > (Output_file::open_base_file): ...this; add base_name and > writable parameters; adjust all callers. > (Output_file::map_no_anonymous): Add writable parameter; adjust all > callers. > * testsuite/Makefile.am (incremental_test_4): Test > --incremental-base. > * testsuite/Makefile.in: Regenerate. > @@ -861,6 +861,7 @@ Incremental_inputs::report_command_line(int argc, const char* const* argv) > || strcmp(argv[i], "--incremental-changed") == 0 > || strcmp(argv[i], "--incremental-unchanged") == 0 > || strcmp(argv[i], "--incremental-unknown") == 0 > + || is_prefix_of("--incremental-base=", argv[i]) > || is_prefix_of("--debug=", argv[i])) > continue; Will this work correctly if the user does ld --incremental-base old-file ? That is, if they pass the argument as a separate argv entry, rather than using =? I guess the same question arises for --debug. > + // If the base file and the output file are different, open a > + // new output file and copy the contents from the base file. > + if (use_base_file) > + { > + unsigned char* base = this->base_; > + this->open(s.st_size); > + memcpy(this->base_, base, s.st_size); > + ::munmap(base, s.st_size); > + ::close(o); > + } You're going to some mild contortions to map in the base file, and then you are throwing away the mapping. If you are going to stick with this copying approach, then I think it would be simpler to just map the output file as for a non-incremental link, and then open() the base file and read() the contents into the mapping you just created. That will be just as efficient--it's a nice sequential read--and will save you from running out of memory when you in effect map the output file twice. Ian