"relocation truncated to fit: R_X86_64_32S against `.bss' Error"
This is a rare error but when you get it there is no way you can get out of it without doing something fancy. If you do an exhaustive search you will find people trying to upgrade their linkers as the issue is definitely with linker. People even tried rebuilding their linker to ignore the relocation errors. Even if you do that you will SEGFAULT at run time.
The reason for this error is the size of data that you are using. This is seen to happen when your program needs more than 2GB of data. Well, who needs such big data at compile time? I do for one and there are other people in the HPC world who do that too. For all of them the life saver or may be a day saver is the compiler option -mcmodel.
All you need to do is to compile your program with
-mcmodel medium option.
For example, I was working with STREAM benchmarking tool from university of Virginia and had this error. To rectify this, I compiled my program with following command:
gcc -mcmodel=medium stream.c -o stream
I have removed additional flags for the sake of simplicity. You might want to use various flags for your program. Please comment if this was helpful.
Yep. This solution worked for me. Thanks for sharing.
ReplyDeleteDude, You are a scholar and a gentleman! This worked perfectly!
ReplyDeleteDear Anony,
ReplyDeleteThank you for those nice words. I am glad to be of some help.
Regards,
Dinesh
Man, this is great!!!. Please forgive my naive questions, what's the equivalent flag for fortran (intel compiler ifort), and what does mcmodel do exactly? (I know that it gives the program more memory but how?).
ReplyDeleteForget about the last comment, I got it. I had the flags in a wrong part of my makefile.
ReplyDeleteHi,
ReplyDeleteJust wanted to say that this worked for me also.
Thank you very much
Dear Anony,
ReplyDeleteI am glad I was of some help.
Regards,
Programmer
this worked for me as well, thank you very much :)
ReplyDelete@Anony,
ReplyDeleteI appreciate your taking time to leave a reply.
Regards,
Programmer
So Beautiful. Thanks a lot Guys. Worked perfectly for me.
ReplyDeleteThanks Dear. Little did I know this post will help so many people. I am glad I could be of some help.
ReplyDeleteI have a warning:
ReplyDelete/tmp/cciXCDL1.s: Assembler messages:
/tmp/cciXCDL1.s:3: Warning: ignoring incorrect section type for .lbss
does anyone knows why?
thanks a bunch...it worked for me
ReplyDeleteThanks a lot. It helped!
ReplyDeleteDear Dinesh,
ReplyDeleteIt worked for me!!! I am very grateful. THANK YOU!
Antonio
Dear Antonio,
ReplyDeleteI am glad it worked for you. I am going back to work on large data soon. Hopefully, this will come handy for me too.
Regards,
Programmer
Thanks for sharing. Although my 64bit kernel still needed a large model, your post pointed out for the solution.
ReplyDeleteBest wishes,
Alex
I got the same error but I am compiling program in fortran. May you tell me how do you modify the compiler in case of fortran please?
ReplyDeleteDear ND,
ReplyDeleteAs far as I knew this option worked for both compilers, especially if we are talking about intel compilers.
You can find more information on http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/64-bit.html
Hope that helps.
Regards,
Dinesh
It worked for me, too :-)
ReplyDeleteHeidi
thank you very much for this post... :)
ReplyDeleteDear Readers,
ReplyDeleteThank you for taking time to leave feedback. It is much appreciated.
Regards,
Dinesh
worked with the gfortran compiler.... many thanks
ReplyDeleteadded -mcmodel=medium
so my compile command was:
gfortran -mcmodel=medium -o a.out interp_GeoidEGM2008_Envisat.f
Work with 64bit ifort 11.159/75 & 12.1.32 on rhel5 and SL6, but need -shared-intel to compile correctly.
ReplyDeleteStrange thing, the same code compile without this option on ifort 12 for OSX
Thank you guys for taking time to leave a comment. Much appreciated.
ReplyDeleteThanks a lot you just saved my evening... I just didn't get why that creepy matrix didn't allocate...
ReplyDeleteThanks a lot, saved me a lot of time today
ReplyDeletethanks a lot...you saved me a lot of time
ReplyDeleteI had the same problem. I compiled it having mcmodel=medium. However, when i run the *.exe, i get a message that zsh : Killed a.f90. Can anyone help me solve this problem
ReplyDeleteThis comment has been removed by the author.
DeleteThanks a lot, it work for me too ;)
DeleteWorks perfect :) thanx
ReplyDeleteAmazing. Thank you so much
ReplyDeletegrateful thanks
ReplyDeleteGrateful, thanks! It helped me compile my fortran code...
ReplyDeletethank you
ReplyDeletewow thanks! Had this problem for a couple of days and decided to Google it. Your site came up first. A life saver!
ReplyDeleteI was always using the mcmodel=medium flag while compiling and there were no issues. However, now with gfortran I get the same error and with intel it is all fine.
ReplyDeletegfortran -mcmodel=medium -J mod_s0 -o c.x c.F
/tmp/cc6Vmggd.s: Assembler messages:
/tmp/cc6Vmggd.s:40: Warning: ignoring incorrect section type for .
I appreciate any suggestions
Warning: ignoring incorrect section type for .lbss
ReplyDeleteThis I got rid of by using -mcmodel=large instead of -mcmodel=medium. This is with gfortran!! strange when it works fine with the latter in intel.
Hi,
ReplyDeleteI was getting same error when using gfortran, and I used -mcmodel=medium and now the code compiles fine. However at run time, I get Segmentation fault error. Any suggestion on this?
Thanks!
Thank you for the tip. It worked also with pgf compiler
ReplyDeleteThanks a lot friend. It worked perfectly.
ReplyDeleteNice post... thank you so much
ReplyDeleteI am using fortran in two different computers, in one worked your command but in the other one no at all!
ReplyDeleteThanks, man, that helped! Worked with gfortran/gcc version 4.6.3
ReplyDeleteMikhail
Same problems here, got compiled successfully with
ReplyDelete-mcmodel=medium
but when running the program, got error message:
Killed
Anyone can help me?
Hi,
ReplyDeleteI got this this error("relocation truncated to fit: R_X86_64_32S against `.bss' Error") in gfortan, when i was running the following make file, even after using the option -mcmodel=medium
makefile contents
FC = gfortran
OBJINV = wsinv3d.o iodata.o util.o setupop.o mcov.o fwd3d.o\
solve3d.o fwd2d.o fwd1d.o divcorr.o sens3d.o representer.o search.o\
blas1.o blas2_3.o LAPACK_C16.o LAPACK_R8.o
wsinv3d : $(OBJINV)
$(FC) -mcmodel=medium -O3 -g $(OBJINV) -o wsinv3dmt
$(OBJINV): para.h
Kindly help me
I appreciate any suggestions
Thanks
Chinna Reddy
Thank you Dinesh. Your post was super awesome
ReplyDeleteThanks so much. It helped me a lot.
ReplyDeletethis also helped me to compile my program
ReplyDeleteThanks a ton
Thanks a ton man...this worked perfectly well.
ReplyDeleteBy the way I tried the same, -mcmodel=medium with a lower config pc, and it just killed the program. Any inputs?
This worked for us. Thanks for the help!
ReplyDeleteA life saver!!
ReplyDeleteThanks for sharing this.
ReplyDeleteA Seismology student.
Worked for me, thanks!
ReplyDeleteThanks.. you saved my life..
ReplyDeleteThanks a lot, It helped me a lot.
ReplyDelete"life saver" works!! Thank you very much!! :D
ReplyDeleteThanks... it gave my life back.
ReplyDeleteomg! u r true life saver! thanks a lot!
ReplyDeleteThank you very much for this advice !
ReplyDeleteI was using intel compilers.
ReplyDeleteAdding -mcmodel=medium worked for me. Thank you so much.
thank's. saved my week....
ReplyDeleteThank you very much for sharing this usefull piece of information!
ReplyDeleteThanks for your help !
ReplyDeleteWow, it works. Thanks a lot!
ReplyDeletewow thanks a lot. It works for me
ReplyDeleteGreat!!! This solve my program issue.
ReplyDeleteThanks!!!!
Thank you!!!
ReplyDeletewhat is the header file that is to be used ?
ReplyDeleteHi! Thanks a lot for taking the time to put this entry! It is really helping people! :D
ReplyDeleteThanks and good luck!
Thank you a lot! :)
ReplyDeleteI have a filename- eof_surfacetemperature.f
ReplyDeleteI am trying to compile this program using ifort -mkl eofsurfacetemperature.f command.
Can you please tell me how to combine -mcmodel=medium option in this command as I am seeing the error : relocation truncated to fit R_X86_64_32
It worked for my file. Wow!!. Thank you very much.
ReplyDeleteThanks you so much because the information is very useful for me. tuyen dung digital marketing manager o tphcm
ReplyDeleteThank You and that i have a dandy provide: Where To Start With Whole House Renovation house renovation ideas
ReplyDelete