Which Env. will trigger R_X86_64_PC32 relocation issue

With PGI 11.8 and later, it’s still suffering the ‘overflow in R_X86_64_PC32 relocation’ issue on certain 64-bit Linux box if without spcifying -fPIC/mcmodel=medium for compile and link, but there is completely no this sort of issue on certain 64-bit Linux box even if without specifying -fPIC/mcmodel=medium for link and compile

I know this issue can be fixed by using -fPIC/mcmodel=medium, but tired always need to add/remove them by manual.

Just wondering

  1. Which sort of Env. will trigger R_X86_64_PC32 relocation issue?

  2. How to force to link with 64-bit offset based on the references instead 32-bit by default without using -fPIC/mcmodel=medium?

  3. Or how to change the system Env. settings to avoid R_X86_64_PC32 relocation issue?


    Thanks

Jerry

Hi Jerry,

By default, Linux uses the small memory model. This means that the static offset between the executable code and all the data in the data section is accessible within 32-bits.

Hence, you have one of two options:

Use -fpic/-mcmodel=medium so the base offset to the data is re-locatable.
or
Use less static data, typically by changing static arrays to be dynamically allocated.


Why this would occur on some Linux systems but not others, I’m not sure. I would guess however, that your static data is large but different assemblers and linkers will put in different static data and those difference could put you over the 32-bit offset. Another possibility is which libraries are being linked and if they are being linked statically or dynamically.

  • Mat