home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pmafire!news.dell.com!swrinde!mips!sdd.hp.com!hpscdc!cupnews0.cup.hp.com!hppad.waterloo.hp.com!hppad!hpfcso!mjs
- From: mjs@hpfcso.FC.HP.COM (Marc Sabatella)
- Newsgroups: comp.sys.hp
- Subject: Re: Problem with C++ or the loader
- Message-ID: <7371185@hpfcso.FC.HP.COM>
- Date: 28 Jul 92 22:14:23 GMT
- References: <1992Jul24.145817.27910@bnlux1.bnl.gov>
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Lines: 86
-
- In comp.sys.hp, aharon@bnlux1.bnl.gov (Aharon Friedman) writes:
-
- > I am trying to link a c++ code I am getting the following message:
- >
- > ld: initialized data space not big enough for COMM declaration of gain
- >
- > Where gain is a variable in one of the objects.
-
- I posted the following reply to a similar question a few weeks ago:
-
- In comp.sys.hp, bj@zephir.uucp (Beat Jucker) writes:
-
- > ld: initialized data space not big enough for
- > COMM declaration of _resourceList
- >
- > Does someone know which parameters I have to change? I'm using HP-UX 8.0
- > and the standard K&R C-compiler coming with the system.
-
- This message indicates an error in the program or one of the libraries, not a
- parameter that can simply be bumped up. What has happened is that somewhere in
- your program or in one of the libraries was a declaration of the form
-
- <type1> resourceList;
-
- and somewhere else there was a declaration of the form
-
- <type2> resourceList = <initializer>
-
- where type1 is bigger than type2. For instance,
-
- int resourceList;
-
- and
-
- double resourceList = 3.14;
-
- Or a more likely example,
-
- struct list resourceList;
-
- and
-
- struct list *resourceList = &resourceListHead;
-
- The linker is trying to tell you it is allocating enough space for the
- initialized definition, but the uninitialized one is bigger, and the source
- file that contains the bigger definition may well be expecting the larger
- allocation.
-
- Note declarations with the keyword "extern" do not in fact define anything, so
- there are not germane.
-
- To find all definitions of resourceList, try running
-
- nm *.[oa] | grep -v "0x00000000 U" | grep "_resourceList"
-
- The lines are are screening out are the "extern" declarations; this leaves us
- with only true definitions.
-
- Lines that look like
-
- 0x00000004 U
-
- are uninitialized definitions, where the number at left indicates the expected
- size. Lines that look like
-
- 0x00004F54 D
-
- are initialized definitions, where the number at left indicates the address
- where the initial value is stored. The size is *not* recorded; the linker
- guesses that by finding the initialized definition at the next higher address
- and subtracting addresses. This should always overestimate and never
- underestimate, so you should never see the error message unless the initialized
- definition really is too small.
-
- If you are having trouble finding the conflicting definitions using "nm", you
- might want to try the undocumented "-y" option to the 300/400 linker, which
- works as documented for the 700/800. If you are using "cc" to link, specify
- "-Wl,-y,_resourceList". This will show you where the linker is seeing all
- definitions and references to that symbol.
-
- --------------
- Marc Sabatella (marc@hpmonk.fc.hp.com)
- Disclaimers:
- 2 + 2 = 3, for suitably small values of 2
- Bill (H.) and Dave (P.) may not always agree with me
-