Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
585 views
in Technique[技术] by (71.8m points)

How to solve ERROR: relocation truncated to fit R_X86_64_PC32 in C

For my algorithm I have to test it with large arrays. So, in my C code I have two global static arrays of length n.

#define length 10000000

static long long arr1[length+1];
static long long arr2[length+1];

For this length n it works fine. But when I make it 10 times (length 100000000) it shows a particular error many times.

 relocation truncated to fit||R_X86_64_PC32 against symbol `__imp_Sleep' defined in .idata$5 section in C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dqifs01360.o)|
 relocation truncated to fit||R_X86_64_PC32 against symbol `__imp_SetUnhandledExceptionFilter' defined in .idata$5 section in C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dqifs01346.o)|
...
...

Codeblock compilation command

gcc.exe -Wall -g -Wall  -c "D:otherall testmain.c" -o objDebugmain.o
gcc.exe  -o "binDebugall test.exe" objDebugmain.o   

I knew that it may causes as the address may be larger to link variables. So, I tried every one of this at a time in the command but, the error is same.

-mcmodel=medium

-Wl,--image-base -Wl,0x10000000

-fno-unwind-tables -fno-asynchronous-unwind-tables

-fPIC

How can I solve this problem???

question from:https://stackoverflow.com/questions/65919466/how-to-solve-error-relocation-truncated-to-fit-r-x86-64-pc32-in-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...