public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* static instanciation in libraries stripped by the linker
@ 2004-09-06 12:25 kadreg
  2004-09-06 12:47 ` Why does this segfault, big struct: too big? Jack Liddle
  2004-09-07 13:04 ` static instanciation in libraries stripped by the linker Eljay Love-Jensen
  0 siblings, 2 replies; 4+ messages in thread
From: kadreg @ 2004-09-06 12:25 UTC (permalink / raw)
  To: gcc-help; +Cc: jpequery

I have a huge application, all its object files in a single library file due to
a bash limitation for command line size. This file is about 715 megabytes.

I link using the command:
    g++ -o myApplication mybiglib.a

and I obtains a single file of 2 megabytes.

This file only contains the loader for the application. Normally, this
application is instanciated by static parts, which seems to not be in the final
file.

Is the a way to ask to the linker to keep all this parts of the application, and
not losing it, like if I use a simple set of object files.

Jérôme Péquery.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Why does this segfault, big struct: too big?
  2004-09-06 12:25 static instanciation in libraries stripped by the linker kadreg
@ 2004-09-06 12:47 ` Jack Liddle
  2004-09-07 12:33   ` Eljay Love-Jensen
  2004-09-07 13:04 ` static instanciation in libraries stripped by the linker Eljay Love-Jensen
  1 sibling, 1 reply; 4+ messages in thread
From: Jack Liddle @ 2004-09-06 12:47 UTC (permalink / raw)
  To: gcc-help

When I compile the following code I get a strange intermittent segfault.

Compiling with

gcc -lm -O -Wall mk2.c -o mk2

Case 1)  Pbars = 400,  final "printf" statement present -> No seg fault,
GDB says exits with code 04
Case 2)  Pbars = 500,  final "printf" statement present -> Seg faults

Program received signal SIGSEGV, Segmentation fault.
0x0804841c in main (argc=1, argv=0xbfffdc44) at 2dhistomk2.c:43
43         printf("junk");

Case 3) Pbars >= 500, final "printd" statement NOT present -> NO seg
fault,  GDB says exits with code 01

This fault occurs as part of a longer code,  the printf statement triggers
the problem as do other calls like "srand48(0)"

I can't imagine why the size of a struct is important and why these
statements would trigger this.  Everything seems to be linked OK, with a
lower value of Pbars full code does exactly what it should do.

OH Yeah

gcc -v, gives me

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)

Yours very confused

Jack Liddle
Theoretical Physics
University Of Oxford

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>


//Adjust these for your run
#define Sbars 440
#define Smin 875
#define Smax 985

#define Pmin 0
#define Pmax 2
#define Pbars 400

#define Nblocks 20


struct histogrambar
{
  double Sstart;
  double Sfinish;
  double Pstart;
  double Pfinish;
  double number;


};
typedef struct histogrambar Histogrambar;

struct histogram
{
  struct histogrambar bar[Sbars][Pbars];
};

typedef struct histogram Histogram;


int main(int  argc,char **argv)
{
   Histogram hist;
   printf("junk");
}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why does this segfault, big struct: too big?
  2004-09-06 12:47 ` Why does this segfault, big struct: too big? Jack Liddle
@ 2004-09-07 12:33   ` Eljay Love-Jensen
  0 siblings, 0 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2004-09-07 12:33 UTC (permalink / raw)
  To: Jack Liddle, gcc-help

Hi Jack,

The structure is too big to fit on the stack.

Either increase your stack, or allocate the structure in the heap.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: static instanciation in libraries stripped by the linker
  2004-09-06 12:25 static instanciation in libraries stripped by the linker kadreg
  2004-09-06 12:47 ` Why does this segfault, big struct: too big? Jack Liddle
@ 2004-09-07 13:04 ` Eljay Love-Jensen
  1 sibling, 0 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2004-09-07 13:04 UTC (permalink / raw)
  To: kadreg, gcc-help; +Cc: jpequery

Hi Jerome,

g++ -o myApplication -Wl,--whole-archive mybiglib.a -Wl,--no-whole-archive

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-07 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-06 12:25 static instanciation in libraries stripped by the linker kadreg
2004-09-06 12:47 ` Why does this segfault, big struct: too big? Jack Liddle
2004-09-07 12:33   ` Eljay Love-Jensen
2004-09-07 13:04 ` static instanciation in libraries stripped by the linker Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).