Search code examples
cgccassemblycompilationi386

What kind of error is this "c(.text+0x7): relocation truncated to fit: 8 .data"


I was compiling/linking my program

i386-gcc -o output.lnx func.opc mainc.opc

and I kept getting that error. I honestly have no idea what this means.

Any clue?

thanks,


Solution

  • This is usually a symptom of having too much code or data in the program. The relocation at offset 7 in .text segment (code) has been compiled with a fixed size (2 or 4), but the data/instruction it is referring to is more than 64k or 2G away.

    Other than that, I can't tell you how to fix it without actually seeing the object files. Useful tools for pinpointing the problem are objdump (with flags -dr) and readelf programs.