x86: use encoding_length() also elsewhere
authorJan Beulich <jbeulich@suse.com>
Mon, 1 Jul 2019 06:25:33 +0000 (08:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 1 Jul 2019 06:25:33 +0000 (08:25 +0200)
gas/ChangeLog
gas/config/tc-i386.c

index b4bf405b98a96e5e92d50cc65663685cd82fd2d8..664cd145ca8a662a8645b2a6eda956acb06bc68e 100644 (file)
@@ -1,3 +1,7 @@
+2019-07-01  Jan Beulich  <jbeulich@suse.com>
+
+       * tc-i386.c (output_disp, output_imm): Use encoding_length.
+
 2019-07-01  Jan Beulich  <jbeulich@suse.com>
 
        * tc-i386.c (encoding_length): New.
index 84c4bc5020a3a52deea881efe74fd142a73d474e..f6c14c9ac78f7c7a8cbb4234295fdbb63e15b59c 100644 (file)
@@ -8540,25 +8540,11 @@ output_disp (fragS *insn_start_frag, offsetT insn_start_off)
                                   == O_subtract))))
                      || reloc_type == BFD_RELOC_32_PCREL))
                {
-                 offsetT add;
-
-                 if (insn_start_frag == frag_now)
-                   add = (p - frag_now->fr_literal) - insn_start_off;
-                 else
-                   {
-                     fragS *fr;
-
-                     add = insn_start_frag->fr_fix - insn_start_off;
-                     for (fr = insn_start_frag->fr_next;
-                          fr && fr != frag_now; fr = fr->fr_next)
-                       add += fr->fr_fix;
-                     add += p - frag_now->fr_literal;
-                   }
-
                  if (!object_64bit)
                    {
                      reloc_type = BFD_RELOC_386_GOTPC;
-                     i.op[n].imms->X_add_number += add;
+                     i.op[n].imms->X_add_number +=
+                       encoding_length (insn_start_frag, insn_start_off, p);
                    }
                  else if (reloc_type == BFD_RELOC_64)
                    reloc_type = BFD_RELOC_X86_64_GOTPC64;
@@ -8703,28 +8689,14 @@ output_imm (fragS *insn_start_frag, offsetT insn_start_off)
                               (i.op[n].imms->X_op_symbol)->X_op)
                              == O_subtract))))
                {
-                 offsetT add;
-
-                 if (insn_start_frag == frag_now)
-                   add = (p - frag_now->fr_literal) - insn_start_off;
-                 else
-                   {
-                     fragS *fr;
-
-                     add = insn_start_frag->fr_fix - insn_start_off;
-                     for (fr = insn_start_frag->fr_next;
-                          fr && fr != frag_now; fr = fr->fr_next)
-                       add += fr->fr_fix;
-                     add += p - frag_now->fr_literal;
-                   }
-
                  if (!object_64bit)
                    reloc_type = BFD_RELOC_386_GOTPC;
                  else if (size == 4)
                    reloc_type = BFD_RELOC_X86_64_GOTPC32;
                  else if (size == 8)
                    reloc_type = BFD_RELOC_X86_64_GOTPC64;
-                 i.op[n].imms->X_add_number += add;
+                 i.op[n].imms->X_add_number +=
+                   encoding_length (insn_start_frag, insn_start_off, p);
                }
              fix_new_exp (frag_now, p - frag_now->fr_literal, size,
                           i.op[n].imms, 0, reloc_type);