From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7348 invoked by alias); 21 Dec 2012 10:40:19 -0000 Received: (qmail 7338 invoked by uid 22791); 21 Dec 2012 10:40:19 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_20,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-ie0-f176.google.com (HELO mail-ie0-f176.google.com) (209.85.223.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Dec 2012 10:40:14 +0000 Received: by mail-ie0-f176.google.com with SMTP id 13so5926731iea.7 for ; Fri, 21 Dec 2012 02:40:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.43.83.1 with SMTP id ae1mr11498622icc.24.1356086413670; Fri, 21 Dec 2012 02:40:13 -0800 (PST) Received: by 10.43.5.199 with HTTP; Fri, 21 Dec 2012 02:40:13 -0800 (PST) In-Reply-To: References: <1355719810.9320.ezmlm@gcc.gnu.org> Date: Fri, 21 Dec 2012 10:40:00 -0000 Message-ID: Subject: Re: why is g++ relocation error linking only showing when listing objects explicitly? From: Jonathan Wakely To: "Mark Galeck (CW)" Cc: "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00116.txt.bz2 On 21 December 2012 09:38, Mark Galeck (CW) wrote: > Hello, > > I had posted the question below 5 days ago but there were no replys. At t= hat time, it was a mere curiosity. But now, what appeared to work then, ac= tually does not work... So now I am in trouble and I have more symptoms. > > What is going on, and how do I get g++ linker to work here?? > > ------------------------ > > Previous message: > > (...) > when using g++ to link about 2300 .o files into a single library, total s= ize about 29MB, and -mlongcall does not help. > (...) > This doesn't work (24-bit relocation error) > >>g++ -fPIC `` > > > However, this works correctly (!!!???) > >>echo `` | xargs g++ -fPIC > > --------------------- > > > Now: > Actually, the second version also does not work. It does not give an err= or message, and there appears a big library. BUT: Some symbols are defin= ed in some object files, but then become undefined in the resulting library= !!! > > If I decrease the number of object files to about 1200, the symbols in qu= estion vanish completely from the library!!! > > Finally, if I decrease the number of object files further to about 800, t= he symbols in question are present in the library again, and this time defi= ned as they should. > > > > > Please anybody knows what could be happening??? I don't know what the relocation error is about, but it's not surprising that using xargs doesn't help. See the man page for xargs: The command line for command is built up until it reaches a system-defined limit (unless the -n and -L options are used). The specified command will be invoked as many times as neces=E2=80=90 sary to use up the list of input items. So xargs is splitting up your command into: g++ -fPIC g++ -fPIC g++ -fPIC Each of these commands will produce an output file containing some of the objects, then the next command will overwrite that file with a new output file containing different objects. Have you thought about adding the objects to an archive instead of trying to link 2300 objects in a single command? You can add new objects to an archive, so it wouldn't have to be done in a single command.