--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -15081,13 +15081,26 @@ i386_finalize_displacement (segT exp_seg
       || i.reloc[this_operand] == BFD_RELOC_X86_64_GOTPCREL
       || i.reloc[this_operand] == BFD_RELOC_64_GOTOFF)
     {
-      if (exp->X_op != O_symbol)
+      if (exp->X_op != O_symbol
+	  && exp->X_op != O_add
+	  && exp->X_op != O_subtract)
 	goto inv_disp;
 
       if (S_IS_LOCAL (exp->X_add_symbol)
 	  && S_GET_SEGMENT (exp->X_add_symbol) != undefined_section
 	  && S_GET_SEGMENT (exp->X_add_symbol) != expr_section)
 	section_symbol (S_GET_SEGMENT (exp->X_add_symbol));
+
+      if (exp->X_op != O_symbol)
+	{
+	  if (S_IS_LOCAL (exp->X_op_symbol)
+	      && S_GET_SEGMENT (exp->X_op_symbol) != undefined_section
+	      && S_GET_SEGMENT (exp->X_op_symbol) != expr_section)
+	    section_symbol (S_GET_SEGMENT (exp->X_op_symbol));
+
+	  exp->X_add_symbol = make_expr_symbol (exp);
+	}
+
       exp->X_op = O_subtract;
       exp->X_op_symbol = GOT_symbol;
       if (i.reloc[this_operand] == BFD_RELOC_X86_64_GOTPCREL)
--- a/gas/testsuite/gas/i386/x86-64-gotpcrel-2.d
+++ b/gas/testsuite/gas/i386/x86-64-gotpcrel-2.d
@@ -8,4 +8,6 @@ Disassembly of section .text:
 
 0+ <foo>:
  +[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax        # 7 <foo\+0x7>	3: R_X86_64_GOTPCREL	foo-0x4
+ +[a-f0-9]+:	ff 35 00 00 00 00    	push   0x0\(%rip\)        # .*	9: R_X86_64_GOTPCREL	foo\+0x4
+ +[a-f0-9]+:	ff 35 00 00 00 00    	push   0x0\(%rip\)        # .*	f: R_X86_64_GOTPCREL	foo-0xc
 #pass
--- a/gas/testsuite/gas/i386/x86-64-gotpcrel-2.s
+++ b/gas/testsuite/gas/i386/x86-64-gotpcrel-2.s
@@ -1,3 +1,7 @@
 	.text
 foo:
 	movq	foo@GOTPCREL(%rip), %rax
+	push	foo@GOTPCREL + eight(%rip)
+	push	foo@GOTPCREL - eight(%rip)
+
+	.equ eight, 8
