mirror of
https://github.com/fadden/6502bench.git
synced 2024-07-04 16:30:01 +00:00
Fix handling of data formatting that overlaps with code
If you play games with code hints you can create a data operand that overlaps with code. This causes problems (see issue #45). We now check for that situation and ignore overlapping data descriptors. Added a regression test to 2011-hinting.
This commit is contained in:
parent
e7d693bae2
commit
62b7655a1c
|
@ -858,6 +858,31 @@ namespace SourceGen {
|
||||||
genLog.LogW("+" + offset.ToString("x6") +
|
genLog.LogW("+" + offset.ToString("x6") +
|
||||||
": unexpected mid-instruction format descriptor");
|
": unexpected mid-instruction format descriptor");
|
||||||
continue; // ignore this one
|
continue; // ignore this one
|
||||||
|
} else {
|
||||||
|
// Data or inline data. The data analyzer hasn't run yet. We want to
|
||||||
|
// confirm that the descriptor doesn't overlap with code.
|
||||||
|
//
|
||||||
|
// Data descriptors that overlap code are problematic, for two reasons.
|
||||||
|
// First, we end up with references to hidden labels, because the code that
|
||||||
|
// tries to prevent it sees an Anattrib with code at the target address and
|
||||||
|
// assumes all is well. Second, if the overlap ends partway into an
|
||||||
|
// instruction, an Anattrib-walker will move from a data region to the middle
|
||||||
|
// of an instruction, which should never happen.
|
||||||
|
//
|
||||||
|
// All instruction bytes have been marked, so we just need to confirm that
|
||||||
|
// none of the bytes spanned by this descriptor are instructions.
|
||||||
|
bool overlap = false;
|
||||||
|
for (int i = offset; i < offset + kvp.Value.Length; i++) {
|
||||||
|
if (mAnattribs[i].IsInstruction) {
|
||||||
|
genLog.LogW("+" + offset.ToString("x6") +
|
||||||
|
": data format descriptor overlaps code at +" + i.ToString("x6"));
|
||||||
|
overlap = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (overlap) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mAnattribs[offset].DataDescriptor = kvp.Value;
|
mAnattribs[offset].DataDescriptor = kvp.Value;
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
<h1>$ProjectName$ Disassembly</h1>
|
<h1>$ProjectName$ Disassembly</h1>
|
||||||
|
|
||||||
<div id="code-lines">
|
<div id="code-lines">
|
||||||
|
<!-- The CodeLines marker is not optional, and may only appear once -->
|
||||||
$CodeLines$
|
$CodeLines$
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>Symbol Table</h2>
|
<!-- SymbolTable is optional; remove this entire section from the template if you don't want it -->
|
||||||
<div id="symbol-table">
|
<div id="symbol-table">
|
||||||
|
<h2>Symbol Table</h2>
|
||||||
$SymbolTable$
|
$SymbolTable$
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
,,<2C><11>,<2C><><EFBFBD>
|
,,<2C><11>,<2C><><EFBFBD>
|
||||||
ę,˘˙ę V$Š˘" ( V$Š3˘D 7 :ęV$` V$ŠU˘f`
|
ę,˘˙ę V$©˘" ( V$©3˘D : =ęV$ E` V$©U˘f`<60>‚<EFBFBD>©™`
|
|
@ -1,8 +1,8 @@
|
||||||
### 6502bench SourceGen dis65 v1.0 ###
|
### 6502bench SourceGen dis65 v1.0 ###
|
||||||
{
|
{
|
||||||
"_ContentVersion":1,"FileDataLength":63,"FileDataCrc32":977869194,"ProjectProps":{
|
"_ContentVersion":2,"FileDataLength":72,"FileDataCrc32":-800253778,"ProjectProps":{
|
||||||
"CpuName":"6502","IncludeUndocumentedInstr":false,"EntryFlags":33489103,"AnalysisParams":{
|
"CpuName":"6502","IncludeUndocumentedInstr":false,"EntryFlags":33489103,"AutoLabelStyle":"Simple","AnalysisParams":{
|
||||||
"AnalyzeUncategorizedData":true,"MinCharsForString":4,"SeekNearbyTargets":true},
|
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":true,"SmartPlpHandling":true},
|
||||||
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":["PROJ:2011-hinting.cs"],"ProjectSyms":{
|
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":["PROJ:2011-hinting.cs"],"ProjectSyms":{
|
||||||
}},
|
}},
|
||||||
"AddressMap":[{
|
"AddressMap":[{
|
||||||
|
@ -27,4 +27,8 @@
|
||||||
},
|
},
|
||||||
"OperandFormats":{
|
"OperandFormats":{
|
||||||
"51":{
|
"51":{
|
||||||
"Length":3,"Format":"Dense","SubFormat":"None","SymbolRef":null}}}
|
"Length":3,"Format":"Dense","SubFormat":"None","SymbolRef":null},
|
||||||
|
"66":{
|
||||||
|
"Length":4,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null}},
|
||||||
|
"LvTables":{
|
||||||
|
}}
|
||||||
|
|
|
@ -22,14 +22,22 @@ L101B .dword $22a211a9
|
||||||
jsr L1028
|
jsr L1028
|
||||||
jsr $2456
|
jsr $2456
|
||||||
L1028 .dword $44a233a9
|
L1028 .dword $44a233a9
|
||||||
jsr L1037
|
|
||||||
jsr L103A
|
jsr L103A
|
||||||
|
jsr L103D
|
||||||
nop
|
nop
|
||||||
lda $2456
|
lda $2456
|
||||||
|
jsr L1045
|
||||||
rts
|
rts
|
||||||
|
|
||||||
L1037 jsr $2456
|
L103A jsr $2456
|
||||||
L103A lda #$55
|
L103D lda #$55
|
||||||
ldx #$66
|
ldx #$66
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.byte $81
|
||||||
|
.byte $82
|
||||||
|
.byte $83
|
||||||
|
|
||||||
|
L1045 lda #$99
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,22 @@ L101B adrl $22a211a9
|
||||||
jsr L1028
|
jsr L1028
|
||||||
jsr $2456
|
jsr $2456
|
||||||
L1028 adrl $44a233a9
|
L1028 adrl $44a233a9
|
||||||
jsr L1037
|
|
||||||
jsr L103A
|
jsr L103A
|
||||||
|
jsr L103D
|
||||||
nop
|
nop
|
||||||
lda $2456
|
lda $2456
|
||||||
|
jsr L1045
|
||||||
rts
|
rts
|
||||||
|
|
||||||
L1037 jsr $2456
|
L103A jsr $2456
|
||||||
L103A lda #$55
|
L103D lda #$55
|
||||||
ldx #$66
|
ldx #$66
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
dfb $81
|
||||||
|
dfb $82
|
||||||
|
dfb $83
|
||||||
|
|
||||||
|
L1045 lda #$99
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,22 @@ L101B !32 $22a211a9
|
||||||
jsr L1028
|
jsr L1028
|
||||||
jsr $2456
|
jsr $2456
|
||||||
L1028 !32 $44a233a9
|
L1028 !32 $44a233a9
|
||||||
jsr L1037
|
|
||||||
jsr L103A
|
jsr L103A
|
||||||
|
jsr L103D
|
||||||
nop
|
nop
|
||||||
lda $2456
|
lda $2456
|
||||||
|
jsr L1045
|
||||||
rts
|
rts
|
||||||
|
|
||||||
L1037 jsr $2456
|
L103A jsr $2456
|
||||||
L103A lda #$55
|
L103D lda #$55
|
||||||
ldx #$66
|
ldx #$66
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
!byte $81
|
||||||
|
!byte $82
|
||||||
|
!byte $83
|
||||||
|
|
||||||
|
L1045 lda #$99
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,22 @@ L101B: .dword $22a211a9
|
||||||
jsr L1028
|
jsr L1028
|
||||||
jsr $2456
|
jsr $2456
|
||||||
L1028: .dword $44a233a9
|
L1028: .dword $44a233a9
|
||||||
jsr L1037
|
|
||||||
jsr L103A
|
jsr L103A
|
||||||
|
jsr L103D
|
||||||
nop
|
nop
|
||||||
lda $2456
|
lda $2456
|
||||||
|
jsr L1045
|
||||||
rts
|
rts
|
||||||
|
|
||||||
L1037: jsr $2456
|
L103A: jsr $2456
|
||||||
L103A: lda #$55
|
L103D: lda #$55
|
||||||
ldx #$66
|
ldx #$66
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.byte $81
|
||||||
|
.byte $82
|
||||||
|
.byte $83
|
||||||
|
|
||||||
|
L1045: lda #$99
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# 6502bench SourceGen generated linker script for 2011-hinting
|
# 6502bench SourceGen generated linker script for 2011-hinting
|
||||||
MEMORY {
|
MEMORY {
|
||||||
MAIN: file=%O, start=%S, size=65536;
|
MAIN: file=%O, start=%S, size=65536;
|
||||||
# MEM000: file=%O, start=$1000, size=63;
|
# MEM000: file=%O, start=$1000, size=72;
|
||||||
}
|
}
|
||||||
SEGMENTS {
|
SEGMENTS {
|
||||||
CODE: load=MAIN, type=rw;
|
CODE: load=MAIN, type=rw;
|
||||||
|
|
|
@ -51,6 +51,8 @@ magic33 lda #$33
|
||||||
|
|
||||||
lda MAGIC ;EDIT: hint as data, format as dense hex, remove hint
|
lda MAGIC ;EDIT: hint as data, format as dense hex, remove hint
|
||||||
|
|
||||||
|
jsr dataolap
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,3 +61,8 @@ part2 lda #$55
|
||||||
ldx #$66
|
ldx #$66
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; Make sure that data descriptors that overlap with code are ignored.
|
||||||
|
hex 818283 ;EDIT: format as 4-byte int, so it overlaps with dataolap
|
||||||
|
dataolap lda #$99
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user