Index: lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp =================================================================== --- lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp +++ lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp @@ -350,8 +350,11 @@ FixupKind == MCFixupKind(X86::reloc_riprel_4byte_movq_load) || FixupKind == MCFixupKind(X86::reloc_riprel_4byte_relax) || FixupKind == MCFixupKind(X86::reloc_riprel_4byte_relax_rex) || - FixupKind == MCFixupKind(X86::reloc_branch_4byte_pcrel)) + FixupKind == MCFixupKind(X86::reloc_branch_4byte_pcrel)) { ImmOffset -= 4; + if (StartsWithGlobalOffsetTable(Expr) != GOT_None) + FixupKind = MCFixupKind(X86::reloc_global_offset_table); + } if (FixupKind == FK_PCRel_2) ImmOffset -= 2; if (FixupKind == FK_PCRel_1)