https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82725
--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> --- I'm testing following patch: --cut here-- Index: i386.c =================================================================== --- i386.c (revision 254199) +++ i386.c (working copy) @@ -15079,10 +15079,16 @@ legitimate_pic_address_disp_p (rtx disp) break; op0 = XEXP (XEXP (disp, 0), 0); op1 = XEXP (XEXP (disp, 0), 1); - if (!CONST_INT_P (op1) - || INTVAL (op1) >= 16*1024*1024 + if (!CONST_INT_P (op1)) + break; + if (GET_CODE (op0) == UNSPEC + && (XINT (op0, 1) == UNSPEC_DTPOFF + || XINT (op0, 1) == UNSPEC_NTPOFF) + && trunc_int_for_mode (INTVAL (op1), SImode) == INTVAL (op1)) + return true; + if (INTVAL (op1) >= 16*1024*1024 || INTVAL (op1) < -16*1024*1024) - break; + break; if (GET_CODE (op0) == LABEL_REF) return true; if (GET_CODE (op0) == CONST --cut here-- As suggested, the patch allows offsetted UNSPEC_DTPOFF/UNSPEC_NTPOFF relocations in legitimate_pic_address_disp_p. In fact, these are already allowed in x86_64_immediate_operand, with the immediate limited to SImode values.