delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/19/15:50:38

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3BF970D8.B1F67C3B@luukku.com>
Date: Mon, 19 Nov 2001 22:51:36 +0200
From: Kai Ruottu <kai DOT ruottu AT luukku DOT com>
Reply-To: kai DOT ruottu AT luukku DOT com
Organization: MTV3i Internet, Finland
X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Mohammad Saleem <mosa AT enea DOT se>
CC: crossgcc AT sources DOT redhat DOT com, cygwin AT cygwin DOT com
Subject: Re: linking application with a library
References: <21558852 DOT 1006167645775 DOT JavaMail DOT hip-pop AT porkkana>

Mohammad Saleem wrote:
> 
> Hi all,
> 
> I am using h8300-hitachi-hms-gcc cross-complier for building my application.
> I have a lib mylib.a (20 kb) which I want to link with my application.
> My application gets 20 kb bigger as soon as I link it with mylib.a
> without any function being called from mylib.a.

 The linker shouldn't take anything from the lib if it doesn't need anything
from it.

> It seems to me that I have built mylib.a so that the whole lib is linked
> during linking process even if no one method is being called.

 Is the library produced using C++ or ObjC or from where the name 'method'
comes?

> Now my question is which flag should I use to build mylib.a so that only
> those functions are linked which are being called.

 Compiling each function into its own '.o' module is the normal practice,
the linker takes only the needed '.o' files from the archive.
 
> If no function is called then linking mylib.a shouldn't affect the size
> of my application.

 Yes, this should be the case...

 BTW, the H8/300 is a architecture which requires tricks like using
the '__attribute__((eightbit_data))' for the SFRs (I/O-registers) in
order to produce any effective code...  For instance:

-------------------- clip --------------------------------
#define SFR       __attribute__((eightbit_data))

extern volatile unsigned char SFR SCI_SSR0;
extern volatile unsigned char SFR SCI_TDR0;

/*
#define SCI_TDR0 (*(volatile unsigned char *) (0xffffdb))
#define SCI_SSR0 (*(volatile unsigned char *) (0xffffdc))
*/

/* Single char out to the serial port */

void put_ser(unsigned char c)
{
        while ((SCI_SSR0 & 0x80) != 0x80)
                ;
        SCI_TDR0 = c;
        SCI_SSR0 &= 0x7F;
}
-------------------- clip --------------------------------
;       GCC For the Hitachi H8/300
;       By Hitachi America Ltd and Cygnus Support
;       release F-1
; -O2

        .h8300s
        .file   "put_ser.c"
        .section .text
        .align 1
        .global _put_ser
_put_ser:
.L5:
        mov.b   @_SCI_SSR0:8,r2l
        and     #128,r2l
        beq     .L5
        mov.b   r0l,@_SCI_TDR0:8
        bclr    #7,@_SCI_SSR0:8
        rts
        .end
-------------------- clip --------------------------------

 Getting a RISC-like 'load/and/store' operation instead of the
'bclr #7,@_SCI_SSR0:8' is not rare if not using any of these
'tricks'... And if the I/O-ports are used much, much 'code
bloat' will be the result...

Cheers, Kai



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019