Question

relocation truncated to fit: R_X86_64_PC32 against `.bss'

I'm getting this linker error in g++ when compiling:

The rest of the code isn't material since this definition breaks my compilation. The time function is found in sys/time.h. Compiled on 64-Bit RHEL.

 long ntime() {

     struct timeval tp;

     gettimeofday(&tp, (struct timezone *)0);
     return (tp.tv_sec*1000 + tp.tv_usec / 1000);
 }

Tell me why this is wrong?

Thanks in advance.

Was it helpful?

Solution

Not sure why the linker error is occuring, but is there any particular reason for making the struct timeval static? Making it local is just as fast and makes your function threadsafe, while conserving heap (well, bss) space.

Edit: Here's the problem. You've exceeded 2GB in static heap space. Make some of that dynamically allocated, or change the memory model. In gcc this can be done by passing -mcmodel=medium and must be used on all object files. This may increase overhead somewhat, however.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top