Menu

#514 mcs51: Prevent mixed jump sizes in jump tables

None
closed-accepted
None
MCS51
5
1 day ago
4 days ago
No

Fixes [bugs:#4066]:

Peephole 260.i changes all jump table entries to 2-byte sjmp instructions and uses index * 2 to find an entry.
Later, peephole 257.b changes some of them back to 3-byte ljmp instructions.
The entries then have different sizes, this can cause a jump to the wrong location.

This patch adds notInJumpTable() to peephole 257.b so it does not change instructions inside a jump table.

I tested the original failing testcase with the same random configuration, and it now passes.

1 Attachments

Related

Bugs: #4066

Discussion

  • Maarten Brock

    Maarten Brock - 3 days ago
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,5 +1,4 @@
    -Fixes bug #4066:
    -https://sourceforge.net/p/sdcc/bugs/4066/
    +Fixes [bugs:#4066]:
    
     Peephole `260.i` changes all jump table entries to 2-byte sjmp instructions and uses index * 2 to find an entry. 
     Later, peephole `257.b` changes some of them back to 3-byte ljmp instructions. 
    
    • Group: -->
     

    Related

    Bugs: #4066

  • Li-Hsin Chien

    Li-Hsin Chien - 3 days ago

    Updated: bug-4066-v2.patch

    The actual code change is unchanged. I only added a regression test
    based on the original failing gcc-torture-execute-20011109-1.c testcase.

    Please use this version instead of the previous one!

     

    Last edit: Li-Hsin Chien 3 days ago
    • Li-Hsin Chien

      Li-Hsin Chien - 2 days ago

      ChangeLog:

      * src/mcs51/peeph.def (257.b): Do not apply this rule inside jump
        tables.
      * support/regression/tests/bug-4066.c: New regression test.
      
       
  • Maarten Brock

    Maarten Brock - 1 day ago
    • status: open --> closed-accepted
    • assigned_to: Maarten Brock
    • Category: other --> MCS51
     
  • Maarten Brock

    Maarten Brock - 1 day ago

    Applied in [r16836]. Thanks!

     
    🎉
    1

    Related

    Commit: [r16836]


Log in to post a comment.