tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tcc assembler emits wrong pc-relative symbol differen


From: grischka
Subject: Re: [Tinycc-devel] tcc assembler emits wrong pc-relative symbol difference reloctions in immediates
Date: Sun, 3 Mar 2024 20:13:03 +0100
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 01.03.2024 17:32, Rich Felker wrote:
The relocation emitted is the pc-relative address based on the
beginning of the add opcode, but it needs to be based on the beginning
of the immediate operand in the add opcode.

I just moved the addition of (ind + 4)
    
https://repo.or.cz/tinycc.git/commitdiff/ca061f3a96216f85f6fe72868083208aa0a740b9#patch2
to where the operand is put.
    
https://repo.or.cz/tinycc.git/commitdiff/ca061f3a96216f85f6fe72868083208aa0a740b9#patch1
thanks, -- gr


diff --git a/i386-asm.c b/i386-asm.c
index e134d804..63cfbf6b 100644
--- a/i386-asm.c
+++ b/i386-asm.c
@@ -738,6 +738,8 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)

      s = 0; /* avoid warning */

+    int ind0 = ind;
+
  again:
      /* optimize matching by using a lookup table (no hashing is needed
         !) */
@@ -1153,6 +1155,7 @@ again:
            } else if (pa->op_type[i] == OPT_DISP || pa->op_type[i] == 
OPT_DISP8) {
                  gen_disp32(&ops[i].e);
              } else {
+                if (ops[i].e.pcrel) ops[i].e.v += ind-ind0;
                  gen_expr32(&ops[i].e);
              }
          }

Please CC me on replies, as I'm not subscribed.

Rich

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]