Compare commits
20 Commits
setting-cl
...
agent/bitt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22705c905e | ||
|
|
3d3448e3a8 | ||
|
|
654c65dd27 | ||
|
|
bb93684b95 | ||
|
|
39648c8aa6 | ||
|
|
230c3af28f | ||
|
|
13881c99fb | ||
|
|
b26e248bb0 | ||
|
|
8350f2b4df | ||
|
|
3851d2cc74 | ||
|
|
7bdf4629fd | ||
|
|
5a222cdec4 | ||
|
|
ac8d46d231 | ||
|
|
813660b96e | ||
|
|
e82417345a | ||
|
|
230c2f8d34 | ||
|
|
524350ed8f | ||
|
|
c62453dac9 | ||
|
|
6b17698b84 | ||
|
|
f9358f6e46 |
@@ -37,6 +37,9 @@ force_active:
|
||||
|
||||
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
|
||||
block_relocations:
|
||||
# Run establishes a fixed stack at 0x81600000, not __pformatter + 0x280.
|
||||
- source: .text:0x8137B468
|
||||
- source: .text:0x8137B46C
|
||||
- source: .data:0x8165E15C
|
||||
- source: .data:0x8165E19C
|
||||
|
||||
|
||||
@@ -92,18 +92,20 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
|
||||
dst[0] = val;
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
s32 oddLowDifference;
|
||||
s32 oddHighSum;
|
||||
s32 oddHighDifference;
|
||||
s32 dcValue;
|
||||
|
||||
t = b2 - b6;
|
||||
oddLowSum = b5 + b3;
|
||||
b5 = b5 - b3;
|
||||
oddLowDifference = b5 - b3;
|
||||
oddHighSum = b1 + b7;
|
||||
b1 = b1 - b7;
|
||||
oddHighDifference = b1 - b7;
|
||||
u = b6 + b2;
|
||||
t = t * 0xB5 >> 8;
|
||||
x_factor = oddHighSum - oddLowSum;
|
||||
z_factor = b5 + b1;
|
||||
z_factor = oddLowDifference + oddHighDifference;
|
||||
dcValue = block[0];
|
||||
a = dcValue - b4;
|
||||
x = x_factor * 0xB5 >> 8;
|
||||
@@ -113,14 +115,14 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
|
||||
z = z_factor * 0x62 >> 8;
|
||||
w = d + u;
|
||||
y = d - u;
|
||||
m_part = b1 * 0x14E >> 8;
|
||||
m_part = oddHighDifference * 0x14E >> 8;
|
||||
e = a - t;
|
||||
m = m_part - z;
|
||||
oddLowSum += m;
|
||||
n = oddHighSum + oddLowSum;
|
||||
o = x + m;
|
||||
dst[0] = w + n;
|
||||
p_part = b5 * 0x8B;
|
||||
p_part = oddLowDifference * 0x8B;
|
||||
dst[7] = w - n;
|
||||
p_part >>= 8;
|
||||
dst[1] = v + o;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <tmc_jpeg_internal.h>
|
||||
|
||||
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
|
||||
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
|
||||
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
|
||||
|
||||
@@ -280,7 +280,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
|
||||
return -161;
|
||||
}
|
||||
for (index = 0; index < count; index++) {
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
|
||||
entries += 12;
|
||||
}
|
||||
remaining -= entriesSize;
|
||||
@@ -331,19 +331,19 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
|
||||
return -161;
|
||||
}
|
||||
for (index = 0; index < count; index++) {
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
|
||||
entries += 12;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
|
||||
s32 tag;
|
||||
u16 type;
|
||||
u32 type;
|
||||
|
||||
tag = readU16(entry, byteOrder);
|
||||
type = readU16(entry + 2, byteOrder);
|
||||
tag = readExifU16(entry, byteOrder);
|
||||
type = readExifU16(entry + 2, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case 0x0103:
|
||||
@@ -366,7 +366,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->xResNum = readU32(p, byteOrder);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -386,7 +386,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->yResNum = readU32(p, byteOrder);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -501,6 +501,10 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
case 0x8769:
|
||||
case 0x9000:
|
||||
case 0x9101:
|
||||
case 0x011C:
|
||||
case 0xA000:
|
||||
case 0xA001:
|
||||
case 0xA002:
|
||||
case 0xA003: {
|
||||
break;
|
||||
}
|
||||
@@ -516,7 +520,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->xResNumIfd1 = readU32(p, byteOrder);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -538,7 +542,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -816,7 +816,6 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
u8* luminance;
|
||||
u8* cb;
|
||||
u8* cr;
|
||||
s32 value;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 cbValue;
|
||||
@@ -844,17 +843,17 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
for (column = x; column < xEnd; column++) {
|
||||
cbValue = (s8)*cb++;
|
||||
crValue = (s8)*cr++;
|
||||
value = *luminance++;
|
||||
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
|
||||
red = value + ((crValue * 359) >> 8);
|
||||
blue = value + ((cbValue * 454) >> 8);
|
||||
red = *luminance++;
|
||||
green = red + (-(cbValue * 88 + crValue * 183) >> 8);
|
||||
blue = red + ((cbValue * 454) >> 8);
|
||||
red = red + ((crValue * 359) >> 8);
|
||||
if ((blue | green | red) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
red = red > 255 ? 255 : red < 0 ? 0 : red;
|
||||
}
|
||||
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
|
||||
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
|
||||
((blue & 0xF8) >> 3) + (((red & 0xF8) << 8) + ((green & 0xFC) << 3));
|
||||
}
|
||||
luminance += rowSkip;
|
||||
cb += rowSkip;
|
||||
|
||||
@@ -656,10 +656,10 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
blueOffset = (cbValue * 454) >> 8;
|
||||
}
|
||||
{
|
||||
s32 value = *luminance++;
|
||||
s32 green = value + greenOffset;
|
||||
s32 red = value + redOffset;
|
||||
s32 blue = value + blueOffset;
|
||||
s32 red = *luminance++;
|
||||
s32 green = red + greenOffset;
|
||||
s32 blue = red + blueOffset;
|
||||
red = red + redOffset;
|
||||
if ((green | red | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
|
||||
@@ -311,21 +311,21 @@ Zi8UInt Zi8SpellingPY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
|
||||
return length;
|
||||
}
|
||||
|
||||
ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,Zi8UInt key,ziU8 requireFull,ziU8 usePinyin,ziU8 tone)
|
||||
ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,ziU16 key,ziU8 requireFull,ziU8 usePinyin,ziU8 tone)
|
||||
{
|
||||
ziU16 spelling[16];
|
||||
Zi8UInt spellingLength;
|
||||
|
||||
if ((key & 0xffff) == 0) {
|
||||
if (key == 0) {
|
||||
return 0;
|
||||
}
|
||||
if ((inputLength & 0xff) == 0) {
|
||||
return 1;
|
||||
}
|
||||
if (usePinyin != 0) {
|
||||
spellingLength = Zi8SpellingPY(spelling,key & 0xffff,tone & 0xff);
|
||||
spellingLength = Zi8SpellingPY(spelling,key,tone & 0xff);
|
||||
} else {
|
||||
spellingLength = Zi8SpellingZY(spelling,key & 0xffff,tone & 0xff);
|
||||
spellingLength = Zi8SpellingZY(spelling,key,tone & 0xff);
|
||||
}
|
||||
if ((requireFull != 0) && ((inputLength & 0xff) != (spellingLength & 0xff))) {
|
||||
return 0;
|
||||
@@ -1327,7 +1327,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
|
||||
}
|
||||
if (elementIndex == 0) continue;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (candidateCharacter == output[index]) break;
|
||||
}
|
||||
@@ -1396,7 +1396,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
|
||||
}
|
||||
if (elementIndex == 0) continue;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (candidateCharacter == output[index]) break;
|
||||
}
|
||||
@@ -1519,7 +1519,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
|
||||
}
|
||||
if (elementIndex == 0) goto nextPhrase;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (firstOrdinal == output[index]) goto nextPhrase;
|
||||
}
|
||||
@@ -1601,7 +1601,7 @@ finishPhrases:
|
||||
}
|
||||
if (elementIndex == 0) goto nextSortedOrdinal;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
|
||||
ordinal = Zi8Ord2Uni(ordinal,work);
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (ordinal == output[index]) break;
|
||||
@@ -1629,11 +1629,11 @@ nextSortedOrdinal:
|
||||
;
|
||||
}
|
||||
}
|
||||
if ((options->countOnly == '\0') && Zi8GetZHuwdPtr(&userEntries,&userCount,work) != 0)
|
||||
if ((options->countOnly == '\0') && (ziU8)Zi8GetZHuwdPtr(&userEntries,&userCount,work) != 0)
|
||||
{
|
||||
for (phraseOrdinal = 0; phraseOrdinal < userCount;) {
|
||||
if ((params->elementCount == '\0') || ((userEntries[1] & 0x80) != 0)) {
|
||||
userOrdinal = (userEntries[1] & 0x7f) << 8 | (ziU16)userEntries[2];
|
||||
userOrdinal = (ziU16)(userEntries[1] & 0x7f) << 8 | (ziU16)userEntries[2];
|
||||
phraseTable = syllableTable + (Zi8UInt)userOrdinal * 0xc;
|
||||
if (((*phraseTable & languageMask) != 0) &&
|
||||
((characterSetTable == 0 || ((characterSet & characterSetTable[(Zi8UInt)userOrdinal]) != 0)))) {
|
||||
@@ -1654,7 +1654,7 @@ nextSortedOrdinal:
|
||||
}
|
||||
if (elementIndex == 0) goto nextUserOrdinal;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
|
||||
userCharacter = Zi8Ord2Uni(userOrdinal,work);
|
||||
for (duplicateIndex = 0; duplicateIndex < candidateCount; duplicateIndex++) {
|
||||
if (userCharacter == output[duplicateIndex]) break;
|
||||
@@ -1710,7 +1710,7 @@ nextUserOrdinal:
|
||||
if (unicodeCharacter == previousCharacter) goto nextOrdinal;
|
||||
previousCharacter = unicodeCharacter;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (unicodeCharacter == output[index]) break;
|
||||
}
|
||||
@@ -1738,8 +1738,7 @@ nextOrdinal:
|
||||
}
|
||||
finishCandidates:
|
||||
if ((emitWords) && (outputIndex != 0)) {
|
||||
output[outputIndex] = 0;
|
||||
outputIndex++;
|
||||
output[outputIndex++] = 0;
|
||||
}
|
||||
params->count = candidateCount;
|
||||
Zi8LogError(100,work);
|
||||
|
||||
@@ -920,8 +920,7 @@ selectDictionary:
|
||||
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
|
||||
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
|
||||
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
|
||||
wordCursor[1] = *punctuationCursor;
|
||||
punctuationCursor = punctuationCursor + 1;
|
||||
wordCursor[1] = *punctuationCursor++;
|
||||
wordCursor[2] = 0;
|
||||
wordLength = 2;
|
||||
}
|
||||
@@ -1139,7 +1138,7 @@ prepareCandidate:
|
||||
Zi8ChangeWordCase(wordCursor - prefixCount,language,workData);
|
||||
}
|
||||
if ((((ZiAlphaOptions*)optionData)->suffixOnly != '\0') &&
|
||||
((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount))) {
|
||||
((wordLength + prefixCount) > ((ZiAlphaOptions*)optionData)->maxWordLength)) {
|
||||
wordLength = ((ZiAlphaOptions*)optionData)->maxWordLength - prefixCount;
|
||||
wordCursor[wordLength] = 0;
|
||||
}
|
||||
@@ -1208,16 +1207,14 @@ emitCandidate:
|
||||
if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates;
|
||||
} else {
|
||||
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0') {
|
||||
for (index = 0;
|
||||
(index <= (int)wordLength &&
|
||||
(wordCursor[index] == ((ZiAlphaOptions*)optionData)->dictionary[index]));
|
||||
index = index + 1) {
|
||||
for (index = 0; index <= wordLength; index++) {
|
||||
if (wordCursor[index] != ((ZiAlphaOptions*)optionData)->dictionary[index]) break;
|
||||
}
|
||||
if ((((((ZiAlphaWork*)workData)->operation != '\0') || ((int)wordLength <= index))
|
||||
if ((((((ZiAlphaWork*)workData)->operation != '\0') || (index >= wordLength))
|
||||
&& ((((ZiAlphaWork*)workData)->operation == '\0' ||
|
||||
((exactLengthOnly == 0 ||
|
||||
((int)(ziU16)Zi8WCharCount(((ZiAlphaOptions*)optionData)->dictionary,workData) <= index)))))) &&
|
||||
((exactLengthOnly != 0 || ((int)wordLength <= index)))) {
|
||||
(index >= (int)(ziU16)Zi8WCharCount(((ZiAlphaOptions*)optionData)->dictionary,workData))))))) &&
|
||||
((exactLengthOnly != 0 || (index >= wordLength)))) {
|
||||
candidateCount = 1;
|
||||
goto finishCandidates;
|
||||
}
|
||||
@@ -1376,27 +1373,23 @@ finishDictionaryPass:;
|
||||
(((parameters->elementCount == 1 &&
|
||||
(((Zi8GetTableCount(parameters->language,0x1f,workData)) & 0x40) == 0)) &&
|
||||
(*parameters->elements >= 0xeff1)))))) &&
|
||||
((*parameters->elements < 0xf011 &&
|
||||
((*parameters->elements <= 0xf010 &&
|
||||
((Zi8getKeyLayout(parameters->language,*parameters->elements,&punctuationBuffer[0],1,workData)) != '\0')))) {
|
||||
punctuationCandidate = ZI8_TRUE;
|
||||
}
|
||||
if (((candidateCount == 0) && (punctuationCandidate)) && (firstCandidate == 0)) {
|
||||
candidateCount = 1;
|
||||
if ((((ZiAlphaOptions*)optionData)->countOnly == '\0') && ((parameters->getOptions & 0xfd) != 0x81)) {
|
||||
*encodedOutput = 0x3e;
|
||||
encodedOutput[2] = 0;
|
||||
encodedOutput[1] = 0;
|
||||
}
|
||||
else {
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly != 0 || (parameters->getOptions & 0xFD) == 0x81) {
|
||||
if (parameters->getMode == 1) {
|
||||
*wordCursor = *elements;
|
||||
} else {
|
||||
*wordCursor = 0x3E;
|
||||
}
|
||||
else {
|
||||
*wordCursor = 0x3e;
|
||||
}
|
||||
wordCursor[2] = 0;
|
||||
wordCursor[1] = 0;
|
||||
wordCursor = wordCursor + 2;
|
||||
wordCursor[1] = wordCursor[2] = 0;
|
||||
wordCursor += 2;
|
||||
} else {
|
||||
*encodedOutput = 0x3E;
|
||||
encodedOutput[1] = encodedOutput[2] = 0;
|
||||
}
|
||||
if (((ZiAlphaOptions*)optionData)->lookupMode == '\0') {
|
||||
((ZiAlphaWork*)workData)->singleCharacter = 0;
|
||||
@@ -1576,17 +1569,17 @@ checkPrefixFields:
|
||||
|
||||
finishCandidates:
|
||||
((ZiAlphaWork*)workData)->usePrefixAsElements = 0;
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly == '\0') {
|
||||
parameters->letters = candidateCount;
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly != '\0') {
|
||||
parameters->letters = 0;
|
||||
}
|
||||
else {
|
||||
parameters->letters = 0;
|
||||
parameters->letters = candidateCount;
|
||||
}
|
||||
wordCursor[-prefixCount] = 0;
|
||||
if (((((ZiAlphaOptions*)optionData)->countOnly == '\0') && (((ZiAlphaOptions*)optionData)->lookupMode == '\0')) && (parameters->elementCount != 0)) {
|
||||
elementIndex = parameters->elementCount - 1;
|
||||
if (((primaryVowelRestriction) || (secondaryVowelRestriction)) &&
|
||||
((((ZiAlphaWork*)workData)->prefixEnabled < 2 ||
|
||||
((((ZiAlphaWork*)workData)->prefixEnabled <= 1 ||
|
||||
(parameters->elements[elementIndex] == 0xEFF1)))) {
|
||||
index = 0;
|
||||
while (elementIndex >= 0) {
|
||||
|
||||
@@ -749,7 +749,8 @@ s32 pfd_sddrv_get_total_sectors(u32* sectors, u16* bytes_per_sector) {
|
||||
minimum_multiplier = multiplier >= 9 ? multiplier : 9;
|
||||
max_multiplier = minimum_multiplier <= 11 ? minimum_multiplier : 11;
|
||||
multiplier_factor = 1;
|
||||
multiplier_factor <<= (u16)(max_multiplier - 9);
|
||||
max_multiplier = (u16)(max_multiplier - 9);
|
||||
multiplier_factor = (u16)(multiplier_factor << max_multiplier);
|
||||
*sectors = cluster_blocks * multiplier_factor;
|
||||
} else {
|
||||
*sectors = ((csd[1] >> 8 & 0x3fffff) + 1) * 0x400;
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
#include <private/fa/pdm.h>
|
||||
#include <revolution/types.h>
|
||||
#define MBR_WORD(buf, offset) (((pf_u32)(buf)[(offset) + 3] << 24) + ((pf_u32)(buf)[(offset) + 2] << 16) + ((pf_u32)(buf)[(offset) + 1] << 8) + (buf)[offset])
|
||||
static inline pf_u16 read_boot_u16(pf_u8* buf, pf_u32 offset) {
|
||||
if ((pf_u32)&buf[offset] & 1) { return (buf[offset + 1] << 8) | buf[offset]; }
|
||||
return PF_SWAP_16(*(pf_u16*)&buf[(offset + 1) & ~1]);
|
||||
}
|
||||
|
||||
static inline pf_u32 read_partition_u32(const pf_u8* buf, pf_u32 offset) {
|
||||
return (((pf_u32)buf[offset + 2] << 16) + buf[offset]) +
|
||||
(((pf_u32)buf[offset + 3] << 24) + ((pf_u32)buf[offset + 1] << 8));
|
||||
}
|
||||
|
||||
pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
|
||||
pf_s16 index;
|
||||
pf_u32 start[4];
|
||||
@@ -18,8 +22,8 @@ pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mb
|
||||
p_count = count;
|
||||
for (index = 0; index < 4; index++) {
|
||||
*p_start = 0;
|
||||
*p_start = (((pf_u32)buf[456] << 16) + buf[454]) + (((pf_u32)buf[457] << 24) + ((pf_u32)buf[455] << 8));
|
||||
*p_count = (((pf_u32)buf[460] << 16) + buf[458]) + (((pf_u32)buf[461] << 24) + ((pf_u32)buf[459] << 8));
|
||||
*p_start = read_partition_u32(buf, 454);
|
||||
*p_count = read_partition_u32(buf, 458);
|
||||
if (*p_start != 0 && *p_count != 0) {
|
||||
if (index == 0) { *p_is_mbr = 1; }
|
||||
} else {
|
||||
@@ -91,14 +95,14 @@ pf_s32 pdm_part_get_start_sector(PDM_PARTITION* p_part) {
|
||||
if (err != 0) { return err; }
|
||||
pdm_part_is_master_boot_sector(buf, p_part->p_disk->disk_info.total_sectors, &is_mbr);
|
||||
if (is_mbr) {
|
||||
start[0] = MBR_WORD(buf, 454);
|
||||
start[1] = MBR_WORD(buf, 470);
|
||||
start[2] = MBR_WORD(buf, 486);
|
||||
start[3] = MBR_WORD(buf, 502);
|
||||
count[0] = MBR_WORD(buf, 458);
|
||||
count[1] = MBR_WORD(buf, 474);
|
||||
count[2] = MBR_WORD(buf, 490);
|
||||
count[3] = MBR_WORD(buf, 506);
|
||||
start[0] = read_partition_u32(buf, 454);
|
||||
start[1] = read_partition_u32(buf, 470);
|
||||
start[2] = read_partition_u32(buf, 486);
|
||||
start[3] = read_partition_u32(buf, 502);
|
||||
count[0] = read_partition_u32(buf, 458);
|
||||
count[1] = read_partition_u32(buf, 474);
|
||||
count[2] = read_partition_u32(buf, 490);
|
||||
count[3] = read_partition_u32(buf, 506);
|
||||
part_index = 0;
|
||||
for (index = 0; index < 4; index++) {
|
||||
sector = start[index];
|
||||
@@ -112,15 +116,15 @@ pf_s32 pdm_part_get_start_sector(PDM_PARTITION* p_part) {
|
||||
sector = base;
|
||||
for (extended_index = 0; extended_index < 2; extended_index++) {
|
||||
if (extended_index == 0) {
|
||||
sector = sector + MBR_WORD(buf, 454);
|
||||
length = MBR_WORD(buf, 458);
|
||||
sector = sector + read_partition_u32(buf, 454);
|
||||
length = read_partition_u32(buf, 458);
|
||||
err = pdm_disk_physical_read(p_part->p_disk, buf, sector, 1, 512, &success);
|
||||
if (err != 0) { return err; }
|
||||
if (requested == part_index) { p_part->start_sector = sector; p_part->total_sector = length; return 0; }
|
||||
part_index++;
|
||||
} else {
|
||||
sector = base + MBR_WORD(buf, 470);
|
||||
length = MBR_WORD(buf, 474);
|
||||
sector = base + read_partition_u32(buf, 470);
|
||||
length = read_partition_u32(buf, 474);
|
||||
if (sector == 0 || length == 0) { break; }
|
||||
err = pdm_disk_physical_read(p_part->p_disk, buf, sector, 1, 512, &success);
|
||||
if (err != 0) { return err; }
|
||||
|
||||
@@ -557,15 +557,11 @@ static void kbdSendKey(KBDKeyEventData* event) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline u32 kbdChannelFlags(u32 channel) {
|
||||
return kbdData[channel].flags;
|
||||
}
|
||||
|
||||
static void kbd_led_handler(BOOL success, void* callbackArg) {
|
||||
const KBDLEDCallbackData* callback;
|
||||
u32 index;
|
||||
s32 index;
|
||||
u32 err;
|
||||
index = (u32)callbackArg;
|
||||
index = (s32)callbackArg;
|
||||
callback = &kbdLCBuf[index];
|
||||
kbdCmdBuf[index].device = 0;
|
||||
if (callback->callbackAddress == (USBKBDCmdLEDCallback)(u32)kbdCmdBuf[index].device) {
|
||||
@@ -579,12 +575,11 @@ static void kbd_led_handler(BOOL success, void* callbackArg) {
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
kbdLCBuf[index].callbackAddress(err, kbdLCBuf[index].callbackArg);
|
||||
kbdLCBuf[(u32)callbackArg].callbackAddress(err, kbdLCBuf[(u32)callbackArg].callbackArg);
|
||||
}
|
||||
|
||||
USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback, void* callbackArg) {
|
||||
s32 index;
|
||||
u32 ofs;
|
||||
u32 index;
|
||||
u8 ledBits;
|
||||
BOOL interrupts;
|
||||
USBKBDErr result;
|
||||
@@ -594,14 +589,18 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
|
||||
if (channel >= 4) {
|
||||
return 4;
|
||||
}
|
||||
if ((s32)kbdChannelFlags(channel) == 1 || (s32)kbdChannelFlags(channel) == 4) {
|
||||
return 5;
|
||||
{
|
||||
KBDChannel* data = &kbdData[(s32)channel];
|
||||
if ((s32)data->flags == 1 || (s32)data->flags == 4) {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
ledBits = leds;
|
||||
interrupts = OSDisableInterrupts();
|
||||
for (index = 0, ofs = 0; index < 12; index++, ofs += sizeof(KBDLEDCommand)) {
|
||||
if (*(u32*)&((u8*)kbdCmdBuf)[ofs] == 0) {
|
||||
*(u32*)&((u8*)kbdCmdBuf)[ofs] = (u32)kbdData[channel].device;
|
||||
for (index = 0; index < 12; index++) {
|
||||
if (kbdCmdBuf[(s32)index].device == 0) {
|
||||
KBDChannel* data = &kbdData[channel];
|
||||
kbdCmdBuf[(s32)index].device = (u32)data->device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -609,11 +608,14 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
|
||||
if (index == 12) {
|
||||
return 7;
|
||||
}
|
||||
kbdLCBuf[index].callbackAddress = callback;
|
||||
kbdLCBuf[index].callbackArg = callbackArg;
|
||||
result = USBKBDSetLEDAsync((u32)kbdData[channel].device, ledBits,
|
||||
(USBKBDCmdLEDAsync*)&kbdCmdBuf[index],
|
||||
kbd_led_handler, (void*)index);
|
||||
{
|
||||
KBDChannel* data = &kbdData[channel];
|
||||
kbdLCBuf[index].callbackAddress = callback;
|
||||
kbdLCBuf[index].callbackArg = callbackArg;
|
||||
result = USBKBDSetLEDAsync((u32)data->device, ledBits,
|
||||
(USBKBDCmdLEDAsync*)&kbdCmdBuf[index],
|
||||
kbd_led_handler, (void*)index);
|
||||
}
|
||||
switch (result) {
|
||||
default:
|
||||
return 7;
|
||||
@@ -624,7 +626,6 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
|
||||
|
||||
USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
|
||||
u32 index;
|
||||
KBDLEDCommand* command;
|
||||
BOOL interrupts;
|
||||
USBKBDErr result;
|
||||
u8 ledBits;
|
||||
@@ -634,20 +635,16 @@ USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
|
||||
if (channel >= 4) {
|
||||
return 4;
|
||||
}
|
||||
if ((s32)kbdChannelFlags(channel) == 1 || (s32)kbdChannelFlags(channel) == 4) {
|
||||
if ((s32)kbdData[(s32)channel].flags == 1 || (s32)kbdData[(s32)channel].flags == 4) {
|
||||
return 5;
|
||||
}
|
||||
ledBits = leds & 0xff;
|
||||
interrupts = OSDisableInterrupts();
|
||||
index = 0;
|
||||
command = kbdCmdBuf;
|
||||
while (index < 12) {
|
||||
if (command->device == 0) {
|
||||
command->device = (u32)kbdData[channel].device;
|
||||
for (index = 0; index < 12; index++) {
|
||||
if (kbdCmdBuf[(s32)index].device == 0) {
|
||||
kbdCmdBuf[(s32)index].device = (u32)kbdData[channel].device;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
command++;
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
if (index == 12) {
|
||||
@@ -655,7 +652,7 @@ USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
|
||||
}
|
||||
result = USBKBDSetLED((u32)kbdData[channel].device, ledBits,
|
||||
(USBKBDCmdLED*)&kbdCmdBuf[index]);
|
||||
kbdCmdBuf[index].device = 0;
|
||||
kbdCmdBuf[(s32)index].device = 0;
|
||||
switch (result) {
|
||||
default:
|
||||
return 7;
|
||||
|
||||
@@ -169,11 +169,11 @@ static const u32 AESiDecryptTable[] = {
|
||||
};
|
||||
|
||||
#define ROTATE(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#define ENCRYPT(a,b,c,d) (ROTATE(AESiEncryptTable[(a)>>24],24) ^ ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8) ^ AESiEncryptTable[(d)&255])
|
||||
#define DECRYPT(a,b,c,d) (ROTATE(AESiDecryptTable[(a)>>24],24) ^ ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8) ^ AESiDecryptTable[(d)&255])
|
||||
#define SUBSTITUTE(table,a,b,c,d) (((u32)table[(a)>>24]<<24) | ((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8) | table[(d)&255])
|
||||
#define ENCRYPT(a,b,c,d) (((ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[(a)>>24],24)) ^ AESiEncryptTable[(d)&255]) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8))
|
||||
#define DECRYPT(a,b,c,d) (((ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ AESiDecryptTable[(d)&255]) ^ ROTATE(AESiDecryptTable[(a)>>24],24)) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8))
|
||||
#define SUBSTITUTE(table,a,b,c,d) ((((u32)table[(a)>>24]<<24) | table[(d)&255]) | (((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8)))
|
||||
|
||||
#define SUBSTITUTE_XOR(table,a,b,c,d) (((u32)table[(a)>>24]<<24) ^ ((u32)table[((b)>>16)&255]<<16) ^ ((u32)table[((c)>>8)&255]<<8) ^ table[(d)&255])
|
||||
#define SUBSTITUTE_XOR(table,a,b,c,d) (((((u32)table[(a)>>24]<<24) ^ table[(d)&255]) ^ ((u32)table[((c)>>8)&255]<<8)) ^ ((u32)table[((b)>>16)&255]<<16))
|
||||
|
||||
void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
u32 rounds = context->rounds;
|
||||
@@ -210,9 +210,9 @@ void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
u32 twice=DOUBLE_BYTES(value);
|
||||
u32 four=DOUBLE_BYTES(twice);
|
||||
u32 eight=DOUBLE_BYTES(four)^value;
|
||||
u32 mixed=eight ^ (four ^ ROTATE(eight,8));
|
||||
mixed ^= twice ^ ROTATE(mixed,8);
|
||||
mixed ^= value ^ ROTATE(mixed,8);
|
||||
u32 mixed=(ROTATE(eight,8) ^ (eight ^ four));
|
||||
mixed=(ROTATE(mixed,8) ^ (mixed ^ twice));
|
||||
mixed=(ROTATE(mixed,8) ^ (mixed ^ value));
|
||||
keys[word]=mixed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ s32 NHTTPi_strcmp(const char* left, const char* right) { return strcmp(left,righ
|
||||
void* NHTTPi_memclr(void* destination, u32 size) { return memset(destination,0,size); }
|
||||
|
||||
static int LowerCase(int character) {
|
||||
if((character>='A') & (character<='Z')) character+=32;
|
||||
return character;
|
||||
return ((character >= 'A') & (character <= 'Z')) ? character + 32 : character;
|
||||
}
|
||||
|
||||
s32 NHTTPi_strnicmp(const char* left, const char* right, s32 length) {
|
||||
@@ -127,12 +126,13 @@ s32 NHTTPi_intToStr(char* destination, u32 value) {
|
||||
}
|
||||
|
||||
s32 NHTTPi_compareToken(const char* left, const char* right) {
|
||||
for (;;) {
|
||||
int rightCharacter=LowerCase(*right);
|
||||
int leftCharacter=LowerCase(*left);
|
||||
if(leftCharacter!=rightCharacter) break;
|
||||
if(*left==0 || *left==' ') return 0;
|
||||
++left; ++right;
|
||||
u8 rawLeft;
|
||||
while (LowerCase((s8)(rawLeft = *(const u8*)left)) == LowerCase(*right)) {
|
||||
if ((s8)rawLeft == 0 || (s8)rawLeft == ' ') {
|
||||
return 0;
|
||||
}
|
||||
++left;
|
||||
++right;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -161,13 +161,16 @@ s32 NHTTPi_Base64Encode(char* destination, const char* source) {
|
||||
static char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
const char* table=alphabet;
|
||||
char* output=destination;
|
||||
u32 length=strlen(source);
|
||||
s32 length=strlen(source);
|
||||
s32 consumed=0;
|
||||
for(; consumed<(s32)length; consumed+=3) {
|
||||
output[0]=table[source[0]>>2];
|
||||
output[1]=table[((source[0]&3)<<4)+(source[1]>>4)];
|
||||
output[2]=table[((source[1]&15)<<2)+(source[2]>>6)];
|
||||
output[3]=table[source[2]&63];
|
||||
for(; consumed<length; consumed+=3) {
|
||||
s8 first = source[0];
|
||||
s8 second = source[1];
|
||||
s8 third = source[2];
|
||||
output[0]=table[first>>2];
|
||||
output[1]=table[(second>>4)+((first&3)<<4)];
|
||||
output[2]=table[(third>>6)+((second&15)<<2)];
|
||||
output[3]=table[third&63];
|
||||
source+=3; output+=4;
|
||||
}
|
||||
if(consumed==length+1) output[-1]='=';
|
||||
|
||||
@@ -242,14 +242,63 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
|
||||
extern vu32 BS2VideoMode;
|
||||
extern vu32 __DVDLayoutFormat;
|
||||
|
||||
void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
|
||||
u8 *block = start;
|
||||
for (; blockCount != 0; --blockCount) {
|
||||
__dcbz(block, 0);
|
||||
__dcbf(block, 0);
|
||||
block += 32;
|
||||
}
|
||||
((void (*)(u32))entryPoint)(argument);
|
||||
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
|
||||
// clang-format off
|
||||
#ifdef __MWERKS__
|
||||
nofralloc
|
||||
|
||||
mtctr r5
|
||||
mtlr r3
|
||||
|
||||
li r0, 0
|
||||
li r2, 0
|
||||
li r3, 0
|
||||
li r5, 0
|
||||
li r7, 0
|
||||
li r8, 0
|
||||
li r9, 0
|
||||
li r10, 0
|
||||
li r11, 0
|
||||
li r12, 0
|
||||
li r13, 0
|
||||
li r14, 0
|
||||
li r15, 0
|
||||
li r16, 0
|
||||
li r17, 0
|
||||
li r18, 0
|
||||
li r19, 0
|
||||
li r20, 0
|
||||
li r21, 0
|
||||
li r22, 0
|
||||
li r23, 0
|
||||
li r24, 0
|
||||
li r25, 0
|
||||
li r26, 0
|
||||
li r27, 0
|
||||
li r28, 0
|
||||
li r29, 0
|
||||
li r30, 0
|
||||
li r31, 0
|
||||
|
||||
// The application stack is fixed; it is unrelated to the formatter.
|
||||
lis r1, 0x8160
|
||||
ori r1, r1, 0
|
||||
li r6, 0
|
||||
|
||||
b Run_loop_entry
|
||||
Run_loop:
|
||||
dcbz r4, r0
|
||||
dcbf r4, r0
|
||||
addi r4, r4, 0x20
|
||||
bdnz Run_loop
|
||||
b Run_done
|
||||
Run_done:
|
||||
li r4, 0
|
||||
blr
|
||||
Run_loop_entry:
|
||||
b Run_loop
|
||||
#endif
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) {
|
||||
@@ -803,7 +852,7 @@ void BS2StartGCGame() {
|
||||
OSTime time;
|
||||
|
||||
StartingGame = TRUE;
|
||||
while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) {
|
||||
while (CoverBlock.state != DVD_STATE_IDLE) {
|
||||
}
|
||||
|
||||
soundMode = SCGetSoundMode();
|
||||
@@ -1796,21 +1845,24 @@ invalidRvlRegion:
|
||||
State = BS2_STT_RESET_SYSTEM;
|
||||
break;
|
||||
}
|
||||
if (GamePartition == 0) {
|
||||
if (GamePartition != 0) {
|
||||
State = BS2_STT_37;
|
||||
} else {
|
||||
State = BS2_STT_54;
|
||||
break;
|
||||
}
|
||||
State = BS2_STT_37;
|
||||
case 0x25:
|
||||
case 0x25: {
|
||||
u32 partitionOffset = (u32)((DVDPartitionInfo *)GamePartition)->partition;
|
||||
if (BS2BootFromCache != 0) {
|
||||
BS2Report("Open partition from cache.dat\n");
|
||||
NandPending = 1;
|
||||
BS2NANDDivideReadAsync(&BS2CacheFileInfo, &PartitionParams.tmd, 0x4a00, BS2NANDCallback, &BS2NandBlock);
|
||||
} else
|
||||
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
|
||||
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, partitionOffset, BS2DVDCallback);
|
||||
PartitionOpen = 1;
|
||||
State = BS2_STT_38;
|
||||
break;
|
||||
}
|
||||
case 0x26: {
|
||||
status = CheckBS2CommandStatus();
|
||||
if (status == 0)
|
||||
@@ -1837,13 +1889,16 @@ invalidRvlRegion:
|
||||
titlePrefix = titleCode >> 0x18;
|
||||
titleCharacters[3] = (u8)titleCode;
|
||||
titleCharacters[0] = (char)(titleCode >> 0x18);
|
||||
if (titlePrefix < 'R') {
|
||||
if (titlePrefix == 'D')
|
||||
goto check_title_region;
|
||||
} else if (titlePrefix < 'U')
|
||||
switch (titlePrefix) {
|
||||
case 'D':
|
||||
case 'R':
|
||||
case 'S':
|
||||
case 'T':
|
||||
goto check_title_region;
|
||||
regionMatches = TRUE;
|
||||
goto title_region_checked;
|
||||
default:
|
||||
regionMatches = TRUE;
|
||||
goto title_region_checked;
|
||||
}
|
||||
{
|
||||
check_title_region:
|
||||
if (titleCharacters[3] == 0x41) {
|
||||
@@ -2001,8 +2056,8 @@ invalidRvlRegion:
|
||||
if (status == 0)
|
||||
OSPanic("BS2Mach.c", 0x12c8, "BS2 ERROR >>> Cannnot alloc 0x%08x from MEMAllocator", bannerFile.length);
|
||||
BannerLength = bannerFile.length;
|
||||
BannerBuffer = OSRoundDown32B(BannerAllocation) + 32;
|
||||
BS2Report("BannerBufferAddr : %08X\n");
|
||||
BannerBuffer = BannerAllocation + 32 - BannerAllocation % 32;
|
||||
BS2Report("BannerBufferAddr : %08X\n", BannerBuffer);
|
||||
} else {
|
||||
if ((BannerBuffer != 0) && (BannerLength != 0)) {
|
||||
if (BannerLength < ((bannerFile.length + 0x1fU) & 0xffffffe0))
|
||||
|
||||
@@ -7207,7 +7207,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
u32 cmpLow;
|
||||
struct {
|
||||
CHANSVmObjType operandTypes[2];
|
||||
u64 floatBits;
|
||||
double floatLiteral;
|
||||
CHANSVmObjHdr copies[2];
|
||||
CHANSVmObjHdr load;
|
||||
CHANSVmObjHdr operand;
|
||||
@@ -7291,8 +7291,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
case CHANS_VM_OP_LOAD_FLOAT: {
|
||||
opSize = 9;
|
||||
operandBuf = VmGetOperand(vm, 1, 9);
|
||||
memcpy(&scratch.floatBits, operandBuf, 8);
|
||||
result = CHANSVmSetFloat(vm, &pVm->accumulator, *(double*)&scratch.floatBits);
|
||||
memcpy(&scratch.floatLiteral, operandBuf, 8);
|
||||
result = CHANSVmSetFloat(vm, &pVm->accumulator, scratch.floatLiteral);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7769,8 +7769,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
arrayIdx = (u32)stackPtr->value.int_v;
|
||||
goto set_index_ok;
|
||||
case CHANS_VM_OBJ_TYPE_FLOAT: {
|
||||
double stackFloat = *(double*)stackPtr;
|
||||
if (stackFloat <= 4294967294.0 && 0.0 <= stackFloat) {
|
||||
double stackFloat = stackPtr->value.float_v;
|
||||
if (stackFloat >= 0.0 && stackFloat <= 4294967294.0) {
|
||||
arrayIdx = (u32)stackFloat;
|
||||
goto set_index_ok;
|
||||
}
|
||||
@@ -8004,34 +8004,27 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
if (pVm->pActiveCtx->stackDepth != 0 && pVm->pObjStackTopBuf + sizeof(CHANSVmObjHdr) <= pVm->pHeapEnd) {
|
||||
CHANSVmObjHdr* stackTop = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
|
||||
isTypeMatch = 0;
|
||||
if (pVm->accumulator.type == stackTop->type) {
|
||||
if (stackTop->type == pVm->accumulator.type) {
|
||||
switch (stackTop->type) {
|
||||
case CHANS_VM_OBJ_TYPE_INTEGER: {
|
||||
u32 low1 = *(u32*)stackTop;
|
||||
u32 low2 = *(u32*)&pVm->accumulator;
|
||||
u32 high1 = *((u32*)stackTop + 1);
|
||||
u32 high2 = *((u32*)&pVm->accumulator + 1);
|
||||
u32 xor1 = low1 ^ low2;
|
||||
u32 xor2 = high1 ^ high2;
|
||||
isTypeMatch = !(xor1 | xor2);
|
||||
isTypeMatch = stackTop->value.int_v == pVm->accumulator.value.int_v;
|
||||
goto end_branch_check;
|
||||
}
|
||||
case CHANS_VM_OBJ_TYPE_FLOAT: {
|
||||
double stackFloat = stackTop->value.float_v;
|
||||
double accFloat = pVm->accumulator.value.float_v;
|
||||
isTypeMatch = stackFloat == accFloat ? 1 : 0;
|
||||
isTypeMatch = stackTop->value.float_v == pVm->accumulator.value.float_v;
|
||||
goto end_branch_check;
|
||||
}
|
||||
case CHANS_VM_OBJ_TYPE_STRING: {
|
||||
u32 len1, len2;
|
||||
CHANSVmObjHdr* stackObj = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
|
||||
const vmWStringObjVal* accumulatorString = pVm->accumulator.value.wstring_v;
|
||||
const vmWStringObjVal* stackString = stackTop->value.wstring_v;
|
||||
u32 strEqual;
|
||||
isTypeMatch = 0;
|
||||
len1 = stackObj->value.wstring_v->len;
|
||||
len2 = pVm->accumulator.value.wstring_v->len;
|
||||
len1 = stackString->len;
|
||||
len2 = accumulatorString->len;
|
||||
if (len1 == len2) {
|
||||
strEqual = 0;
|
||||
if (len1 == 0 || memcmp(stackObj->value.wstring_v->spData, pVm->accumulator.value.wstring_v->spData, len1) == 0) {
|
||||
if (len1 == 0 || memcmp(stackString->spData, accumulatorString->spData, len1) == 0) {
|
||||
strEqual = 1;
|
||||
}
|
||||
if (strEqual) {
|
||||
|
||||
@@ -1379,30 +1379,34 @@ namespace ipl {
|
||||
return;
|
||||
}
|
||||
|
||||
ext_ead::www::BrowserThread* browser = surface->GetBrowserThread();
|
||||
if (browser == NULL) {
|
||||
// One pointer, overwritten by the standard-buffer fetch, so the
|
||||
// browser `this` and standardBuffer share a callee-saved reg.
|
||||
void* held = surface->GetBrowserThread();
|
||||
if (held == NULL) {
|
||||
return;
|
||||
}
|
||||
if (browser->GetTextureBuffer(0, NULL) == NULL) {
|
||||
if (static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ext_ead::www::BrowserWindow* browserWindow =
|
||||
static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
|
||||
if ((browserWindow != NULL ? browserWindow->unk_0x2C4[3] : 0) != 0) {
|
||||
static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
|
||||
if ((browserWindow == NULL ? 0 : browserWindow->unk_0x2C4[3]) != 0) {
|
||||
unk_0x91C[2] = 1;
|
||||
mState = 0;
|
||||
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
|
||||
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
|
||||
if (browserWindow != NULL) {
|
||||
browserWindow->unk_0x2C4[3] = 0;
|
||||
}
|
||||
www::trasition::ScrollState scrollState = www::trasition::GetScrollState();
|
||||
browserScrollDirection = scrollState == www::trasition::SCROLL_LEFT
|
||||
? 1
|
||||
: (scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0);
|
||||
if (scrollState == www::trasition::SCROLL_LEFT) {
|
||||
browserScrollDirection = 1;
|
||||
} else {
|
||||
browserScrollDirection = scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0;
|
||||
}
|
||||
www::trasition::ResetScrollState();
|
||||
void* changedWideBuffer = browser->GetTextureBuffer(1, NULL);
|
||||
void* changedStandardBuffer = browser->GetTextureBuffer(0, NULL);
|
||||
void* changedWideBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, NULL);
|
||||
void* changedStandardBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL);
|
||||
OSReport("changed %p %p\n", changedStandardBuffer, changedWideBuffer);
|
||||
ext_ead::www::Heap::reportLeaHeap();
|
||||
}
|
||||
@@ -1415,8 +1419,9 @@ namespace ipl {
|
||||
|
||||
WWWRect* standardRect;
|
||||
WWWRect* wideRect;
|
||||
void* wideBuffer = browser->GetTextureBuffer(1, &wideRect);
|
||||
void* standardBuffer = browser->GetTextureBuffer(0, &standardRect);
|
||||
void* wideBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, &wideRect);
|
||||
held = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, &standardRect);
|
||||
void* standardBuffer = held;
|
||||
nw4r::ut::Rect projection4x3;
|
||||
System::getProjectionRect4x3(&projection4x3);
|
||||
int screenWidth = abs(static_cast<int>(projection4x3.GetWidth()));
|
||||
@@ -1443,33 +1448,33 @@ namespace ipl {
|
||||
int wideWidth = abs(static_cast<int>(projection16x9.GetWidth()));
|
||||
int wideHeight = abs(static_cast<int>(projection16x9.GetHeight()));
|
||||
f32 wideLeft = -wideWidth / 2;
|
||||
f32 wideTop = wideHeight / 2;
|
||||
f32 wideTopL = wideHeight / 2;
|
||||
f32 wideRight = wideWidth / 2;
|
||||
nw4r::ut::Rect leftSide(wideLeft, wideTop,
|
||||
f32 wideTopR = wideHeight / 2;
|
||||
nw4r::ut::Rect leftSide(wideLeft, wideTopL,
|
||||
wideLeft + sideDescriptor->textureHeader->width,
|
||||
wideTop - sideDescriptor->textureHeader->height);
|
||||
wideTopL - sideDescriptor->textureHeader->height);
|
||||
nw4r::ut::Rect rightSide(wideRight - sideDescriptor->textureHeader->width,
|
||||
wideTop, wideRight, wideTop - sideDescriptor->textureHeader->height);
|
||||
|
||||
wideTopR, wideRight, wideTopR - sideDescriptor->textureHeader->height);
|
||||
if (browserScrollDirection != 0) {
|
||||
nw4r::lyt::Material* wideMaterial =
|
||||
void* wideMaterial =
|
||||
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex0");
|
||||
nw4r::lyt::Material* firstStandardMaterial =
|
||||
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex1");
|
||||
nw4r::lyt::Material* secondStandardMaterial =
|
||||
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex2");
|
||||
wideMaterial->SetTexture(0, wideTexture);
|
||||
static_cast<nw4r::lyt::Material*>(wideMaterial)->SetTexture(0, wideTexture);
|
||||
firstStandardMaterial->SetTexture(0, standardTexture);
|
||||
secondStandardMaterial->SetTexture(0, standardTexture);
|
||||
mpChangeLayout->FindPaneByName("N_Tra0")->SetVisible(true);
|
||||
if (browserScrollDirection == 1) {
|
||||
utility::FrameController* animation = mpSecondAnimation;
|
||||
animation->initFrame();
|
||||
animation->restart();
|
||||
wideMaterial = mpSecondAnimation;
|
||||
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
|
||||
static_cast<utility::FrameController*>(wideMaterial)->restart();
|
||||
} else {
|
||||
utility::FrameController* animation = mpFirstAnimation;
|
||||
animation->initFrame();
|
||||
animation->restart();
|
||||
wideMaterial = mpFirstAnimation;
|
||||
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
|
||||
static_cast<utility::FrameController*>(wideMaterial)->restart();
|
||||
}
|
||||
mpChangeLayout->calc();
|
||||
browserScrollDirection = 0;
|
||||
@@ -1509,13 +1514,44 @@ namespace ipl {
|
||||
}
|
||||
|
||||
if (mpWiiSettingFlag->smthMsgData >= 2 && mpWiiSettingFlag->smthMsgData <= 7) {
|
||||
GXRenderModeObj renderMode = *System::getRenderModeObj();
|
||||
GXRenderModeObj* pRmode = System::getRenderModeObj();
|
||||
GXRenderModeObj renderMode;
|
||||
volatile GXRenderModeObj* srcMode = pRmode;
|
||||
volatile GXRenderModeObj* dstMode = &renderMode;
|
||||
int n = 12;
|
||||
u8* src;
|
||||
u8* dst = &renderMode.aa;
|
||||
src = &pRmode->aa;
|
||||
dstMode->viTVmode = srcMode->viTVmode;
|
||||
dstMode->fbWidth = srcMode->fbWidth;
|
||||
dstMode->efbHeight = srcMode->efbHeight;
|
||||
dstMode->xfbHeight = srcMode->xfbHeight;
|
||||
dstMode->viXOrigin = srcMode->viXOrigin;
|
||||
dstMode->viYOrigin = srcMode->viYOrigin;
|
||||
dstMode->viWidth = srcMode->viWidth;
|
||||
dstMode->viHeight = srcMode->viHeight;
|
||||
dstMode->xFBmode = srcMode->xFBmode;
|
||||
dstMode->field_rendering = srcMode->field_rendering;
|
||||
dstMode->aa = srcMode->aa;
|
||||
for (; n != 0; n--) {
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[2];
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
dstMode->vfilter[0] = srcMode->vfilter[0];
|
||||
dstMode->vfilter[1] = srcMode->vfilter[1];
|
||||
dstMode->vfilter[2] = srcMode->vfilter[2];
|
||||
dstMode->vfilter[3] = srcMode->vfilter[3];
|
||||
dstMode->vfilter[4] = srcMode->vfilter[4];
|
||||
dstMode->vfilter[5] = srcMode->vfilter[5];
|
||||
dstMode->vfilter[6] = srcMode->vfilter[6];
|
||||
u32 left;
|
||||
u32 top;
|
||||
u32 width;
|
||||
u32 height;
|
||||
GXGetScissor(&left, &top, &width, &height);
|
||||
GXSetScissor(0, renderMode.efbHeight / 2 - 0xA4, renderMode.fbWidth, 0x132);
|
||||
GXSetScissor(0, dstMode->efbHeight / 2 - 0xA4, dstMode->fbWidth, 0x132);
|
||||
mpMainLayout->draw();
|
||||
GXSetScissor(left, top, width, height);
|
||||
}
|
||||
|
||||
@@ -931,17 +931,15 @@ void CArGBAOdh::cdj_c_makeHeader(SArCDJ_OdhMaster* master, u32 size) {
|
||||
}
|
||||
|
||||
s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int format) {
|
||||
u32 paddedWidth;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u8* workPlane;
|
||||
int sourceStride;
|
||||
u8* crPlane;
|
||||
u8* cbPlane;
|
||||
u8* crPlane;
|
||||
u16* dimensions;
|
||||
int rowIndex;
|
||||
int sourceStride;
|
||||
int i;
|
||||
u16 dimension;
|
||||
u16 paddedDimensions[2];
|
||||
|
||||
dimensions = &master->width;
|
||||
@@ -952,11 +950,11 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
|
||||
height = dimensions[1];
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
dimension = dimensions[i];
|
||||
if ((dimension & 7) != 0) {
|
||||
paddedDimensions[i] = (dimension + 8) - (dimension & 7);
|
||||
u16 remainder = dimensions[i] & 7;
|
||||
if (remainder != 0) {
|
||||
paddedDimensions[i] = (dimensions[i] + 8) - remainder;
|
||||
} else {
|
||||
paddedDimensions[i] = dimension;
|
||||
paddedDimensions[i] = dimensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -972,13 +970,12 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
|
||||
}
|
||||
}
|
||||
|
||||
paddedWidth = paddedDimensions[0];
|
||||
for (rowIndex = 0; rowIndex < (s32)height; rowIndex++) {
|
||||
LineConv11(sourceData + (rowIndex & 3) * 8 + rowIndex / 4 * sourceStride, workPlane, cbPlane, crPlane,
|
||||
dimensions[0], dimensions[1], (const long*)gArConvPlttTbl, format);
|
||||
workPlane += paddedWidth;
|
||||
cbPlane += paddedWidth;
|
||||
crPlane += paddedWidth;
|
||||
workPlane += paddedDimensions[0];
|
||||
cbPlane += paddedDimensions[0];
|
||||
crPlane += paddedDimensions[0];
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -978,33 +978,37 @@ namespace ipl {
|
||||
ESMisc::ChangeUid(SYSMENU_TITLE_ID);
|
||||
}
|
||||
|
||||
static inline void DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
|
||||
static inline s32 DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
|
||||
ESTicketView* ticketViewList = NULL;
|
||||
s32 ret;
|
||||
memset(ticketViews, 0, OSRoundUp32B(sizeof(ESTicketView)));
|
||||
ret = ES_GetTicketViews(titleId, NULL, ticketViewCount);
|
||||
if (ret != ES_ERR_OK) {
|
||||
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
|
||||
} else if (*ticketViewCount != 0) {
|
||||
ticketViewList = (ESTicketView*)heap->alloc(*ticketViewCount * OSRoundUp32B(sizeof(ESTicketView)), -DEFAULT_ALIGN);
|
||||
ret = ES_GetTicketViews(titleId, ticketViewList, ticketViewCount);
|
||||
goto cleanup;
|
||||
}
|
||||
if (*ticketViewCount == 0) {
|
||||
return ret;
|
||||
}
|
||||
ticketViewList = (ESTicketView*)heap->alloc(*ticketViewCount * OSRoundUp32B(sizeof(ESTicketView)), -DEFAULT_ALIGN);
|
||||
ret = ES_GetTicketViews(titleId, ticketViewList, ticketViewCount);
|
||||
if (ret != ES_ERR_OK) {
|
||||
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
|
||||
goto cleanup;
|
||||
}
|
||||
for (u32 j = 0; j < *ticketViewCount; j++) {
|
||||
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
|
||||
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
|
||||
if (ret != ES_ERR_OK) {
|
||||
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
|
||||
} else {
|
||||
for (u32 j = 0; j < *ticketViewCount; j++) {
|
||||
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
|
||||
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
|
||||
if (ret != ES_ERR_OK) {
|
||||
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret,
|
||||
((ESTicketView*)ticketViews)->ticketId);
|
||||
}
|
||||
}
|
||||
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret,
|
||||
((ESTicketView*)ticketViews)->ticketId);
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (ticketViewList != NULL) {
|
||||
heap->free(ticketViewList);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline s32 InitSavedata(EGG::Heap* heap) {
|
||||
@@ -1032,20 +1036,23 @@ namespace ipl {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < titleCount; i++) {
|
||||
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
|
||||
verifySavedataZD(heap, titleIds[i], &fileInfo);
|
||||
continue;
|
||||
}
|
||||
switch (titleIds[i]) {
|
||||
case 0x0001000844495343ULL:
|
||||
case 0x000100014A4F4449ULL:
|
||||
case 0x0001000148415858ULL:
|
||||
case 0x0001000844564458ULL:
|
||||
case 0x000100084449534BULL:
|
||||
ES_DeleteTitle(titleIds[i]);
|
||||
DeleteTicketsForce(heap, titleIds[i], ticketViews, &ticketViewCount);
|
||||
break;
|
||||
{
|
||||
u8* ticketScratch = ticketViews;
|
||||
for (u32 i = 0; i < titleCount; i++) {
|
||||
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
|
||||
verifySavedataZD(heap, titleIds[i], &fileInfo);
|
||||
continue;
|
||||
}
|
||||
switch (titleIds[i]) {
|
||||
case 0x0001000844495343ULL:
|
||||
case 0x000100014A4F4449ULL:
|
||||
case 0x0001000148415858ULL:
|
||||
case 0x0001000844564458ULL:
|
||||
case 0x000100084449534BULL:
|
||||
ES_DeleteTitle(titleIds[i]);
|
||||
DeleteTicketsForce(heap, titleIds[i], ticketScratch, &ticketViewCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# CHANSVm typed comparison reconstruction
|
||||
|
||||
Baseline: ec75ddb0. This candidate is separate from the accepted load-string and opcode-error-path work. Those commits and their logs are unchanged. Only CHANSVm.c and this log changed; no headers, linking classifications, metadata, or original assets changed.
|
||||
|
||||
## Retained reconstruction
|
||||
|
||||
- LOAD_FLOAT copies the eight-byte literal into a double scratch member and passes that value directly. This replaces a u64 temporary followed by a double-pointer reinterpretation. Scratch alignment, member offsets, and emitted code are unchanged.
|
||||
- SET_INDEX reads the floating operand through its union member and checks its lower bound before its upper bound, matching the target's comparison order. The accepted interval remains [0, 4294967294], with NaN and infinities rejected.
|
||||
- Strict integer equality uses the declared 64-bit integer values rather than four offset-based u32 loads and manual XOR/OR expressions.
|
||||
- Strict floating equality uses the declared floating values directly.
|
||||
- Strict string equality uses named, read-only payload pointers rather than recreating a header pointer. The stack operand is consistently first in the outer type comparison, following the target.
|
||||
|
||||
This is structural/type reconstruction, not a newly discovered behavior fix. No register forcing, declaration sweep, or alignment padding was introduced.
|
||||
|
||||
## Target evidence
|
||||
|
||||
After rebuilding, the integer-comparison block (Step instructions 1093-1102), floating-comparison block (1103-1108), string-comparison block (1109-1128), and floating-index block (703-712) have the same instructions, control flow, constants, and memory offsets as the target after register names are normalized. This comparison is advisory: register differences remain, and Step is not exact.
|
||||
|
||||
The floating range's instruction forms now use the target's lower-bound-first order. Integer equality emits the same target ten-instruction two-word equality sequence naturally from the 64-bit value comparison. LOAD_FLOAT retains its original eight-byte copy and call sequence without a pointer reinterpretation.
|
||||
|
||||
## Measurements
|
||||
|
||||
- Instruction-exact functions: 221/233 -> 221/233; no previously exact function regressed.
|
||||
- Unit Decompiled/fuzzy: 99.406320% -> 99.413185%.
|
||||
- Step: 96.913800% -> 96.987230%; 1253/1253 instructions; differing positions 285 -> 276.
|
||||
- Exact code: unchanged at 37608/53564 bytes (70.211334%).
|
||||
- Exact data: unchanged at 6904/6904 bytes (100%).
|
||||
- Per-function score regressions: zero.
|
||||
- Unit remains NonMatching/unlinked, with twelve non-exact functions.
|
||||
|
||||
## Attempts
|
||||
|
||||
- Direct 64-bit equality alone: Step 96.933760%, data 100%; retained for combination.
|
||||
- Typed integer/float/string comparison paths: 96.971270%, data 100%; retained.
|
||||
- Those typed paths plus a separate strict-comparison local error result: 1254 instructions, table relocations moved; rejected.
|
||||
- Floating index member access alone preserves the typed-comparison score. Lower-bound-first range checking raises it to 96.983240%, data 100%; retained.
|
||||
- A union literal temporary produced the same code; simplified to a direct double member instead, also with identical code.
|
||||
- Stack-first type comparison raises Step to 96.987230% with unchanged data; retained.
|
||||
|
||||
## Verification
|
||||
|
||||
- Full 43U build passed with the assigned wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
|
||||
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
- pool_diff: all 125 strings identical.
|
||||
- .data: 4672/4672 raw bytes and 352/352 canonical relocations identical.
|
||||
- .rodata: 1432/1432 raw bytes and 258/258 canonical relocations identical.
|
||||
- All 233 functions checked with ctxdiff/odiff: 221 instruction-exact; no falsely exact objdiff functions.
|
||||
- Literal-reference audit: 233 functions analyzed, 40 resolvable call-string arguments checked, no candidates/errors/skips.
|
||||
- Source-extracted host C harnesses passed 20 strict-comparison cases, nine floating-index-bound cases, and eight floating-literal bit patterns. Coverage includes signed integer extremes, differing high words, signed zero, NaN, infinities, strings, references, deletion errors, and literal payload preservation. They stub surrounding dependencies and do not constitute Wii runtime execution.
|
||||
- git diff --check passed.
|
||||
|
||||
Source is paused for independent parent verification.
|
||||
83
tools/decomp-assist/allhands-aes-finalround.attempts.md
Normal file
83
tools/decomp-assist/allhands-aes-finalround.attempts.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# AES final-round word reconstruction, 2026-10-02
|
||||
|
||||
Base: `813660b9` plus local cherry-pick `97035641` of the parent's already queued
|
||||
`fce31442`. The imported candidate and its log are unchanged. This follow-on
|
||||
changes only two final-round expression lines in `libs/RevoEX/src/net/aes.c`
|
||||
and this new log. 43U only; no configuration, metadata, headers or linking edits.
|
||||
|
||||
## Retained reconstruction
|
||||
|
||||
The last cipher round substitutes four bytes, places them in distinct unsigned
|
||||
word lanes, and combines them before AddRoundKey. Encryption combines the high
|
||||
and low lanes, combines the two middle lanes, then ORs those pieces. Decryption
|
||||
combines high/low first, then the lower-middle and upper-middle lanes by XOR.
|
||||
These expressions preserve byte indices, shifts, S-box identity, key traversal,
|
||||
output order and all input/state reads. The four lane contributions are disjoint;
|
||||
all operands are unsigned and have no side effects. No value, algorithmic path,
|
||||
or table is newly invented. This is arithmetic-dependency reconstruction rather
|
||||
than a new implementation or an exact-match claim.
|
||||
|
||||
The target evidence is the original split object's final substitution and
|
||||
packing regions in `AESiEncryptBlock` and `AESiDecryptBlock`. Those regions
|
||||
contain the same sixteen byte loads and word-lane insertion/XOR operations.
|
||||
The retained grouping improves the whole-function instruction similarity at
|
||||
the target's existing body sizes. It does not reproduce every target dependency
|
||||
or register assignment: exact matching remains open, and positional ctxdiff
|
||||
counts are slightly worse despite the improved aligned objdiff scores.
|
||||
|
||||
## Explored alternatives
|
||||
|
||||
- MD5 third-round Boolean grouping and four typed step helpers were tested.
|
||||
The best small Boolean change only reached 94.37255% from 94.30719%; a larger
|
||||
helper reached 94.43791%. Both were discarded as too little benefit for the
|
||||
added change. MD5 source is byte-for-byte unchanged.
|
||||
- Typed inverse-key word, round and complete-schedule helper scopes were tested.
|
||||
A round helper reached 69.72908% decrypt similarity, but interacted poorly
|
||||
with the better final-round grouping. No helper is retained.
|
||||
- Fusing AddRoundKey into each intermediate column regressed both directions.
|
||||
- Typed final-substitution helpers, packed-byte intermediates, and explicit
|
||||
T-table column helpers were evaluated. Their source complexity was unnecessary
|
||||
or they scored below the two retained macro changes.
|
||||
- Twelve unsigned lane-combination expressions were checked for each final-round
|
||||
macro. Two independently improving forms are retained. No register/declaration
|
||||
sweep, assembly, volatile qualifier, undefined value, padding or compiler-option
|
||||
change was used.
|
||||
|
||||
## Verification
|
||||
|
||||
Before -> after:
|
||||
- AESiEncryptBlock: 62.58228 -> 65.81013% fuzzy; 158/158 instructions unchanged;
|
||||
final ctxdiff 137 positional differences (baseline 133).
|
||||
- AESiDecryptBlock: 67.64143 -> 69.69323% fuzzy; 251/251 instructions unchanged;
|
||||
final ctxdiff 227 positional differences (baseline 224).
|
||||
- AES unit: 79.601746 -> 81.09157% fuzzy; exact functions 7/9 and exact code
|
||||
1116/2752 bytes unchanged. Data 2800/2800 (100%) and linking unchanged.
|
||||
- All seven exact AES APIs/CBC functions retain objdiff 100% and ctxdiff diffs 0:
|
||||
NETAESCreateEx 108/108, NETAESCreate 2/2, NETAESDelete 1/1, NETAESEncrypt 46/46,
|
||||
NETAESDecrypt 46/46, NETiAESEncryptoBlock 39/39, NETiAESDecryptoBlock 37/37.
|
||||
- AES pool: all four strings identical. .rodata 2592 bytes and .sdata2 8 bytes
|
||||
identical. .data has the same 197-byte prefix of the 200-byte target, retaining
|
||||
the existing three-byte target alignment extent; no padding was introduced.
|
||||
- MD5 remains unit 96.179825%, ProcessBlock 94.30719% (306/306 instructions),
|
||||
exact functions 3/4, exact code 600/1824, data 456/456. Its three exact APIs
|
||||
retain ctxdiff diffs 0. All 448 .data bytes are identical; .sdata retains its
|
||||
existing one-byte source/seven-byte target-alignment extent difference.
|
||||
- Full 1027-unit report: no exact-function, exact-code, data or fuzzy regression
|
||||
versus the locally imported parent candidate.
|
||||
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
|
||||
`26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
|
||||
Host tests compile production source unchanged with private copies of the existing
|
||||
PPC type/intrinsic shims. Both final AES and the imported parent baseline passed
|
||||
all 2,406 AES-128/192/256 known-answer and seeded randomized CBC checks, including
|
||||
separate/in-place buffers and single/incremental calls. Unchanged MD5 passed all
|
||||
3,088 known-answer/random/chunking checks. The MD5 test supplies RFC1321 padding
|
||||
externally; GetDigest's target-endian length stores remain outside host coverage.
|
||||
|
||||
Private local evidence: `/tmp/crypto-reconstruction-next/` contains baseline/final
|
||||
reports, pool/section/ctxdiff results, full-build.log, host validation scripts and
|
||||
results, and the rejected experiments. No retail assembly or binary is committed
|
||||
or uploaded. Prior worker logs under `/tmp/crypto-remainder/` are untouched.
|
||||
|
||||
GATE: validated partial arithmetic reconstruction with no report regressions.
|
||||
Exact matching and linking remain open. Candidate frozen for parent validation.
|
||||
71
tools/decomp-assist/allhands-aes-rounds.attempts.md
Normal file
71
tools/decomp-assist/allhands-aes-rounds.attempts.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# AES round-expression reconstruction, 2026-10-02
|
||||
|
||||
Separate follow-on to AES key-cursor candidate `2a537c14`. Frozen MD5 candidate
|
||||
`8a6461f9` and prior logs are untouched. This commit changes five expression
|
||||
lines in `libs/RevoEX/src/net/aes.c`, plus this log. 43U only; no linking changes.
|
||||
|
||||
## Evidence and reconstruction
|
||||
|
||||
Target evidence remains the original split `aes.o`, AESiEncryptBlock and
|
||||
AESiDecryptBlock. Both round bodies use four cyclic T-table columns: rotations
|
||||
of 24, 16 and 8 bits plus the unrotated low-byte column. Their XOR dependencies
|
||||
and the inverse-key transform's successive rotate/XOR dependencies lower in a
|
||||
different order from the previous source. The retained expressions associate
|
||||
these same unsigned contributions so compiler scheduling moves closer to the
|
||||
target. Byte indices, rotation counts, table identity, key traversal, row order,
|
||||
loop conditions and final substitution are unchanged.
|
||||
|
||||
The inverse-key transform still computes doubled/four-times/eight-times byte
|
||||
values in the same GF(2^8) representation. Each subsequent stage combines its
|
||||
old mixed value, its 8-bit rotation and the same added contribution. Explicit
|
||||
XOR assignment replaces the compound assignment; all RHS values are evaluated
|
||||
before the assignment, with no side effects or undefined evaluation order.
|
||||
|
||||
No source body or algorithm was missing. This is further instruction-shape
|
||||
reconstruction, not a new functional path or an exact-match claim.
|
||||
|
||||
## Attempts
|
||||
|
||||
- Eight staged column/round helpers and six explicit table-load stages did not
|
||||
improve both functions; reverted.
|
||||
- Tested 120 associative/permutation forms of four T-table contributions,
|
||||
retaining the independent improving expression for each cipher direction.
|
||||
- Tested twelve uniform inverse-key XOR forms plus per-stage refinements. The
|
||||
retained rotate-first XOR form improves all three stages without new helpers.
|
||||
- Array/struct state views, a 15-by-4 round-key view, initial-key cursor forms,
|
||||
and typed table helpers were evaluated. Small gains that required larger
|
||||
changes were rejected, along with all regressions.
|
||||
- No register declaration sweep, inline assembly, volatile qualifier, padding,
|
||||
undefined input, compiler-option change or table change was used.
|
||||
|
||||
## Verification
|
||||
|
||||
Before -> after:
|
||||
- AESiEncryptBlock fuzzy 60.348103 -> 62.58228%; 158/158 instructions unchanged;
|
||||
final ctxdiff has 133 positional differences.
|
||||
- AESiDecryptBlock fuzzy 63.836655 -> 67.64143%; 251/251 instructions unchanged;
|
||||
final ctxdiff has 224 positional differences.
|
||||
- Unit fuzzy 77.700584 -> 79.601746%.
|
||||
- Exact functions 7/9, exact code 1116/2752 bytes, data 2800/2800 (100%), and
|
||||
linked status are unchanged. All seven exact functions retain ctxdiff diffs 0.
|
||||
- All four pool strings match. Table and data source is unchanged.
|
||||
- Frozen MD5 source/metrics are unchanged: unit96.179825%, ProcessBlock94.30719%.
|
||||
- The full 1027-unit report has zero exact-function/code/data/fuzzy regressions
|
||||
against the immediately preceding frozen MD5/AES source report.
|
||||
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
|
||||
`26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
|
||||
`python3 /tmp/crypto-remainder/validate_aes.py` passed all 2,406 production-source
|
||||
known-answer/randomized AES-128/192/256 CBC checks, including in-place buffers
|
||||
and incremental calls. The frozen AES parent source independently passed the
|
||||
same coverage in the same run. Input/key/IV words carry their PPC big-endian
|
||||
numeric values in the native host harness; production source is unmodified.
|
||||
|
||||
Local evidence, not committed or uploaded: `/tmp/crypto-remainder/` contains
|
||||
`aes.xor-results.json`, `aes.invmix-results.json`, `aes-rounds-final.json`,
|
||||
`aes-rounds-AESiEncryptBlock.ctx`, `aes-rounds-AESiDecryptBlock.ctx`,
|
||||
`aes-rounds-vectors.log`, `aes-rounds-full-build.log`, and `validate_aes.py`.
|
||||
No original retail assembly or binary is included in this commit.
|
||||
|
||||
GATE: validated partial arithmetic/data-flow candidate; no regressions. Exact
|
||||
matching and linking remain open.
|
||||
62
tools/decomp-assist/allhands-bs2-tick.attempts.md
Normal file
62
tools/decomp-assist/allhands-bs2-tick.attempts.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# BS2Tick control-flow reconstruction, 2026-10-02
|
||||
|
||||
Baseline BS2Mach source is 449529d9. This candidate changes only BS2Tick in
|
||||
src/BS2/BS2Mach.c. Existing ESMisc and AOSSLink commits remain separate.
|
||||
|
||||
Initial pool_diff: 91/91 strings identical. Read the BS2 round-two/round-three
|
||||
and fz1 attempt records, and compared the current five open functions with
|
||||
fresh target objects. The Run hardware-handoff deficit is separate and is not
|
||||
changed or represented as complete here.
|
||||
|
||||
## Retained source reconstruction
|
||||
|
||||
1. Express the title-family dispatch as the actual sparse set D/R/S/T.
|
||||
The target compares D below R, then dispatches the contiguous R-through-T
|
||||
group using an upper boundary U. The switch restores its branch pair and
|
||||
makes the family set explicit. Exhaustively checked all 256 prefix values.
|
||||
2. Restore the positive game-partition state transition and capture the
|
||||
partition offset at entry to state 0x25, before either cache or disc path.
|
||||
The target loads the partition member before choosing the cache branch;
|
||||
the old source only read it on the disc path. The incoming partition
|
||||
existence check and the state-37 fallthrough remain explicit.
|
||||
3. Restore the banner address diagnostic's missing variadic argument.
|
||||
Target BS2Tick object offsets 0x39B4–0x39D8 compute the aligned banner
|
||||
pointer in r4, store it as BannerBuffer and pass it to BS2Report. The old
|
||||
source supplied the %08X format with no argument on the allocation path.
|
||||
4. Express the same next-cache-line calculation as allocation + 32 minus its
|
||||
remainder modulo 32. This retains the target's strictly-next-line behavior,
|
||||
including when the allocation is already aligned. It does not add padding
|
||||
storage. Checked 196608 address samples including all low 16-bit values at
|
||||
zero, 0x80000000 and near u32 wrap.
|
||||
|
||||
Measured attempts, all retained and individually nonregressing:
|
||||
|
||||
| Attempt | BS2Tick fuzzy | Unit fuzzy |
|
||||
| --- | ---: | ---: |
|
||||
| Baseline | 98.230415% | 98.159485% |
|
||||
| Actual title-family switch | 98.35567% | 98.21673% |
|
||||
| Partition entry and typed member snapshot | 98.58763% | 98.32273% |
|
||||
| Banner diagnostic argument | 98.59278% | 98.32509% |
|
||||
| Explicit next-cache-line remainder | 98.639175% | 98.34629% |
|
||||
|
||||
BS2Tick grows from 1934 to 1937 instructions; target is 1940. The remaining
|
||||
three missing instructions are address-materialization differences, with
|
||||
additional register and instruction-scheduling differences. This is partial
|
||||
reconstruction/matching progress, not an exact function.
|
||||
|
||||
## Verification
|
||||
|
||||
- Full all_source / fresh report / build/43U/ok requested after focused build
|
||||
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
- Exact functions unchanged: 24/29; exact code unchanged: 4940/16980
|
||||
- Data unchanged: 155504/158528 (98.092445%)
|
||||
- Every other unit's report unchanged
|
||||
- The 91-string pool is identical; literal reference audit checks 37 arguments
|
||||
across 24 exact functions with no candidates or errors
|
||||
- Compared all 1027 source objects with the initial snapshot: only previously
|
||||
committed ESMisc and this BS2Mach object differ. BS2Mach .text 16828 -> 16840
|
||||
bytes, 1306 relocations on both sides; .data stays 3020 bytes and 155 jump-table
|
||||
relocations; all other allocated sections/objects are unchanged
|
||||
- git diff --check passes
|
||||
|
||||
No BS2Update, shared-header, metadata, link-flag or assembly change is included.
|
||||
@@ -0,0 +1,99 @@
|
||||
# Alpha comparison and output boundary follow-on, 2026-10-02
|
||||
|
||||
Base: 813660b9 plus unchanged one-key candidate 2ec4a57e, locally fe647fe4.
|
||||
Changed source: libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c only.
|
||||
No ABI, shared header, linking flag or other source change is included.
|
||||
|
||||
## Retained target source structure
|
||||
|
||||
- At function +0x25A8, the suffix truncation condition compares the combined
|
||||
word/prefix length first and branches on less-or-equal. Recovered that
|
||||
operand order. The separate bound check at +0x25E0 has the opposite operand
|
||||
order and is deliberately preserved.
|
||||
- The dictionary lookup comparisons at +0x2948, +0x2978 and +0x2990 compare
|
||||
the dictionary scan index first against word length or the halfword-narrowed
|
||||
dictionary count. Recovered those three relational expressions without
|
||||
changing the count helper's declaration or its halfword conversion.
|
||||
- The punctuation fallback at +0x30F8 compares against 0xF010 and uses a
|
||||
strict greater-than failure branch. Replaced the equivalent < 0xF011 test
|
||||
with <= 0xF010.
|
||||
- The output-count branch at +0x3B08 falls through to clear letters when
|
||||
countOnly is true, and branches to the actual-count store otherwise.
|
||||
Restored that original arm order.
|
||||
- Prefix selection at +0x3B84 compares against 1 and uses less-or-equal.
|
||||
Recovered <= 1 instead of the equivalent < 2.
|
||||
|
||||
These are demonstrated control-flow and expression reconstructions, not
|
||||
register/declaration permutations. No new volatile, assembly, forced register,
|
||||
padding, artificial storage, or undefined value is introduced.
|
||||
|
||||
## Isolated trials and rejected work
|
||||
|
||||
Trials used the live 43U Ninja compiler command, separate source/objects and
|
||||
reports under /tmp/ezi-next, without changing the worktree before selection.
|
||||
Columns: unit fuzzy / matched data bytes / exact functions.
|
||||
|
||||
- Output-count arm order: 96.47729 / 516 / 11
|
||||
- Both inclusive boundary expressions: 96.3798 / 516 / 11
|
||||
- Both maximum-length comparison orders: 96.38128 / 516 / 11
|
||||
- Dictionary comparison order: 96.38405 / 516 / 11
|
||||
- Initial four-group combination: 96.48966 / 516 / 11
|
||||
- Final reviewed combination, preserving the second length comparison's
|
||||
original operand order: 96.52474 / 516 / 11
|
||||
|
||||
Further target-evidenced trials were rejected rather than committed:
|
||||
|
||||
- Safe temporary plus postfix prefix append: 94.71085 / 336 / 11
|
||||
- Safe temporary plus postfix highlighted append: 94.60377 / 336 / 11
|
||||
- Dictionary-kind switches: 96.364845 / 408 / 11
|
||||
- Early candidate skip: 96.451996 / 408 / 11
|
||||
- Combined candidate-count limits: 96.402695 / 408 / 11
|
||||
- Full dictionary source structure plus initial boundary combination:
|
||||
96.78767 / 408 / 11; function extent 0x3DB8 versus 0x3DA8
|
||||
- Explicit prefix-mode byte: 96.40805 / 408 / 11
|
||||
- Explicit element-count byte: 96.3582 / 408 / 11
|
||||
- Skip/count/byte combinations retained extent mismatches and were rejected.
|
||||
|
||||
One-key spelling compound count assignment was codegen-neutral. Prefix
|
||||
increment removed the redundant byte narrowing but worsened allocation:
|
||||
unit 98.23523 -> 97.36198. Neither trial is retained.
|
||||
|
||||
Chinese explicit halfword casts at the two paired phonetic comparisons and
|
||||
an alternative proper halfword return declaration with redundant casts removed
|
||||
both reproduce the previously parked result: unit 96.848755, matched data
|
||||
144 -> 72. Adding the demonstrated component-cursor reload gives 96.489876
|
||||
with the same loss. All remain scratch experiments, with no Chinese edit or
|
||||
neutral PUD ABI commit included.
|
||||
|
||||
## Validation
|
||||
|
||||
Fresh full report: /tmp/ezi-next-alpha-full-report.json.
|
||||
Full-build log: /tmp/ezi-next-alpha-full-build.log.
|
||||
Baseline report: /tmp/ezi-next-baseline.json.
|
||||
|
||||
Zi8AlphaGetCandidates: 95.02813% -> 95.23011%.
|
||||
Unit fuzzy: 96.37759% -> 96.52474%, about 31.88 weighted bytes gained.
|
||||
Exact functions remain 11/12; exact code remains 5880/21664;
|
||||
matched data remains 516/564. No complete unit or new exact function claimed.
|
||||
All 1027 units were compared for fuzzy, matched-code, matched-data and exact
|
||||
function measures: the alpha fuzzy improvement is the sole changed measure,
|
||||
with no regressions.
|
||||
|
||||
Pool checked first: identical and empty. Main function stays 3946/3946
|
||||
instructions and 0x3DA8 bytes, with the same 0x2B0 frame. Strict ctxdiff is
|
||||
nonzero (3738 differences); existing scalar-stack displacement and register
|
||||
allocation remain. Each of the 11 existing exact functions retains identical
|
||||
instruction counts and ctxdiff diffs 0.
|
||||
|
||||
Baseline/candidate .rodata, .data, extab and extabindex have identical payloads
|
||||
and canonical relocations. Relative to the target, extab and extabindex remain
|
||||
byte-identical; the unchanged generated switch relocations remain unmatched.
|
||||
The source rodata's pre-existing 330-byte size versus target 336 is unchanged;
|
||||
objdiff still reports 100% for that section and the same exact-data accounting.
|
||||
Advisory branch mapping checks 709 same-mnemonic branch pairs with zero
|
||||
mapped destination mismatches, and 73/73 helper calls. It is not an exactness
|
||||
or formal equivalence claim.
|
||||
|
||||
Full 43U build passes with the approved wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
|
||||
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
git diff --check passes. No remote actions were performed.
|
||||
@@ -0,0 +1,65 @@
|
||||
# Alpha output and scan reconstruction follow-on, 2026-10-02
|
||||
|
||||
Parent candidate: `94b7f57e`. Its source/log were left unchanged during
|
||||
independent side experiments. No ABI/header/linking changes are included.
|
||||
Changed source: `libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c` only.
|
||||
|
||||
## Target evidence and retained changes
|
||||
|
||||
- At `Zi8AlphaGetCandidates +0x3178`, the original emits wide-character
|
||||
output before the encoded-byte alternative. The wide path assigns the
|
||||
same zero to output elements 2 and 1 (+0x31A4/+0x31A8), then advances by
|
||||
two characters. The encoded path likewise shares its zero assignment.
|
||||
Restored that positive branch and ordinary chained zero assignments.
|
||||
- The dictionary comparison loop branches from +0x2904 to its bound check
|
||||
at +0x292C. The comparison body exits on a character mismatch at +0x2924;
|
||||
a matched character increments the index at +0x2928. Replaced the merged
|
||||
`for` condition with the corresponding bounded loop and explicit break.
|
||||
- The punctuation output block at +0x1B0C..+0x1B1C reads the current cursor,
|
||||
emits its character and advances that same cursor. Expressed this with
|
||||
`wordCursor[1] = *punctuationCursor++`. It does not reuse a mutated index
|
||||
in another operand or introduce an unsequenced read/write.
|
||||
|
||||
## Independently compiled, isolated trials
|
||||
|
||||
Each trial used the exact 43U MWCC flags from the live Ninja command and a
|
||||
separate object/report under `/tmp/ezi-side`, without altering the reviewed
|
||||
worktree candidate. Report columns below are function fuzzy, unit fuzzy,
|
||||
matched data bytes and exact-function count:
|
||||
|
||||
- Early candidate-skip block: 94.65585, 96.10635, 408, 11; excluded
|
||||
- Wide output first: 94.887985, 96.27548, 516, 11; retained
|
||||
- Next-dictionary switches: 94.4037, 95.92264, 408, 11; excluded
|
||||
- Explicit dictionary-scan break: 94.62088, 96.08087, 516, 11; retained
|
||||
- Combined candidate-count limit: 94.35884, 95.88995, 408, 11; excluded
|
||||
- Punctuation cursor increment: 94.4782, 95.97692, 516, 11; retained
|
||||
- Wide output plus scan: 95.02306, 96.37389, 516, 11
|
||||
- Final three-change subset: 95.02813, 96.37759, 516, 11
|
||||
|
||||
## Full current-worktree validation
|
||||
|
||||
Fresh report: `/tmp/ezi-alpha-followup.json`.
|
||||
Full build log: `/tmp/ezi-alpha-followup-build.log`.
|
||||
Exact functions 11/12 unchanged; exact code 5880/21664 unchanged;
|
||||
exact data 516/564 unchanged. Unit fuzzy 95.97323% -> 96.37759%.
|
||||
Function fuzzy 94.47314% -> 95.02813%, about 88 additional weighted bytes.
|
||||
Relative to initial 449529d9, unit fuzzy improves 94.17892% -> 96.37759%.
|
||||
|
||||
Pool first: identical (no narrow strings in either pool).
|
||||
Main function: 3946/3946 instructions, 0x3DA8 bytes each, frame 0x2B0.
|
||||
Strict ctxdiff remains nonzero (3745 differences), dominated by the known
|
||||
scalar-stack displacement, instruction placement and GPR allocation. No
|
||||
new exact function is claimed. Each of the existing 11 exact functions
|
||||
retains identical instruction counts and ctxdiff diffs 0.
|
||||
|
||||
All non-text section scores match the parent: .rodata, extab and extabindex
|
||||
remain 100%; the existing 48-byte generated switch table remains unmatched.
|
||||
The advisory register-normalized/control-flow alignment checked 701 branch
|
||||
pairs with zero destination mismatches and 73/73 helper calls. This is a
|
||||
coverage check, not an exactness claim.
|
||||
|
||||
Full 43U build succeeds with the approved wrapper and
|
||||
`WIBO_SJIS_MISSING_IMPORTS=1`. DOL SHA1:
|
||||
`26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
`git diff --check` succeeds. No new assembly, volatile workaround, register
|
||||
forcing, undefined value, dummy storage, prototype or shared-header change.
|
||||
@@ -0,0 +1,108 @@
|
||||
# One-key candidate boundary reconstruction, 2026-10-02
|
||||
|
||||
Parent commits: alpha 94b7f57e and 35677806, neutral Chinese ABI 105f3b45.
|
||||
This pass changes only `libs/RVLMiddleware/eZiText/src/clib/zi81key.c`.
|
||||
Alpha source/logs and Chinese source/log are unchanged.
|
||||
|
||||
## Retained target-defined boundaries
|
||||
|
||||
- `Zi8IsMatch1Key` consumes a halfword key. Six candidate calls narrow that
|
||||
argument after Zi8GetPCode: target +0x0B0C, +0x0F30, +0x16C0, +0x1BA4,
|
||||
+0x1F4C and +0x22A8. Restored the ziU16 formal and removed its three
|
||||
redundant key masks. The helper itself remains 97/97 instructions,
|
||||
objdiff 100%, ctxdiff diffs 0. All source call sites are in this same unit.
|
||||
- Each of the six duplicate-bit checks consumes a byte result in the target.
|
||||
Made the byte conversion explicit at these call boundaries rather than
|
||||
changing the already-exact full-width duplicate helper.
|
||||
- The user-dictionary availability result is narrowed to a byte at target
|
||||
+0x1E00. The existing full-width declaration remains; the caller now
|
||||
performs the demonstrated conversion explicitly.
|
||||
- User ordinal decoding narrows the masked high byte to a halfword before
|
||||
its shift at target +0x1E44. Recovered that type boundary.
|
||||
- Final output termination stores through the current output index and then
|
||||
increments that index without reloading it (+0x2524..+0x2534). Recovered
|
||||
the ordinary postfix-index store. Its right-hand side is constant zero,
|
||||
so there is no unsequenced index read/write.
|
||||
|
||||
These are source/ABI shape reconstructions with demonstrated target
|
||||
conversions; no callee-saved-register or declaration-order sweep was used.
|
||||
|
||||
## Isolated source trials
|
||||
|
||||
Each trial used the exact 43U Ninja compiler command in `/tmp/ezi-onekey-pass`,
|
||||
without modifying the worktree until the final candidate was selected.
|
||||
Below: candidate-function fuzzy / unit fuzzy / matched data / exact functions.
|
||||
|
||||
- Halfword formal retaining old masks: 95.26784 / 97.65741 / 1232 / 4; rejected
|
||||
- Byte duplicate-helper return: 94.73383 / 97.4822 / 1232 / 5; rejected
|
||||
- Explicit duplicate-result bytes alone: same as preceding; not retained alone
|
||||
- User-dictionary result byte alone: 95.240715 / 97.708664 / 1280 / 5
|
||||
- User ordinal halfword alone: 95.30121 / 97.735695 / 1280 / 5
|
||||
- Combined count-limit increments: 95.106384 / 97.64865 / 1232 / 5; rejected
|
||||
- Terminal postfix index alone: 95.4368 / 97.79627 / 1280 / 5
|
||||
- Halfword formal/old masks + duplicate bytes + limits:
|
||||
95.984566 / 97.97763 / 1232 / 4; rejected
|
||||
- Halfword formal with ordinary typed uses:
|
||||
95.26784 / 97.72078 / 1232 / 5; restores the exact helper
|
||||
- Typed key + duplicate bytes: 95.83312 / 97.97334 / 1280 / 5
|
||||
- Typed key + duplicate bytes + count limits:
|
||||
95.984566 / 98.04101 / 1232 / 5; excluded for data regression
|
||||
- Preceding plus terminal postfix: 96.01794 / 98.055916 / 1232 / 5; excluded
|
||||
- Preceding plus user-dictionary/ordinal conversions:
|
||||
95.926155 / 98.01491 / 1232 / 5; excluded
|
||||
- Typed key + duplicate bytes + terminal postfix:
|
||||
95.858154 / 97.98453 / 1280 / 5
|
||||
- Typed key + duplicate bytes + user-dictionary byte:
|
||||
95.87484 / 97.99198 / 1280 / 5
|
||||
- Typed key + duplicate bytes + ordinal halfword:
|
||||
95.93533 / 98.01901 / 1280 / 5
|
||||
- Typed key + duplicate bytes + terminal postfix + user-dictionary byte:
|
||||
95.86858 / 97.98919 / 1280 / 5
|
||||
- Typed key + duplicate bytes + terminal postfix + ordinal halfword:
|
||||
95.98957 / 98.04324 / 1280 / 5
|
||||
- Final complete boundary subset: 96.41927 / 98.23523 / 1280 / 5
|
||||
|
||||
After selecting that subset, the three count-limit blocks were tested
|
||||
individually against it. OEM: 96.17564 / 98.12637 / 1280 / 5; PUD:
|
||||
95.725075 / 97.92507 / 1232 / 5; phrase: 95.93575 / 98.019196 / 1280 / 5.
|
||||
All three were rejected. No count-limit rewrite remains in the candidate.
|
||||
|
||||
## Full validation and exact data disclosure
|
||||
|
||||
Fresh report `/tmp/ezi-onekey-boundary.json`; full-build log
|
||||
`/tmp/ezi-onekey-boundary-build.log`.
|
||||
|
||||
Unit fuzzy 97.778564% -> 98.23523%. Candidate-function fuzzy
|
||||
95.39716% -> 96.41927%, about 98 fewer weighted deficit bytes.
|
||||
Exact functions remain 5/9; exact code remains 3952/21460;
|
||||
matched data remains 1280/1388. All five baseline exact functions have
|
||||
ctxdiff diffs 0 and identical instruction counts.
|
||||
|
||||
Candidate instructions: 2387 -> 2405 versus target 2397; size
|
||||
0x254C -> 0x2594 versus target 0x2574. Frame remains 0x140.
|
||||
It is not exact, and no new exact function is claimed.
|
||||
|
||||
The spelling tables remain 1152 byte-identical bytes. .sdata2 and extab
|
||||
remain byte-identical at 8 and 72 bytes. The switch table's source is 44
|
||||
bytes versus target 48, the pre-existing four-byte section-alignment tail;
|
||||
all 44 bytes and all eleven canonical relocation targets/addends match.
|
||||
No real data object was resized or renamed and no padding was added.
|
||||
|
||||
The already-unmatched 108-byte extabindex still has two differing bytes at
|
||||
0x4F and 0x5B, with the same 98.14815% section score. They are the function
|
||||
extent words: spelling remains 0x1A94 versus target 0x1A90; candidate extent
|
||||
changes from 0x254C to 0x2594 versus target 0x2574. This is changed unmatched
|
||||
metadata, not a claim that all data bytes are unchanged.
|
||||
|
||||
Pool check: identical (no narrow strings). Advisory branch mapping: all 351
|
||||
pairs preserve their destination and all 71 helper calls correspond. A
|
||||
register-value-aware linear audit pairs 621 observable store/call/branch
|
||||
effects. The seven missing byte-boundary differences are resolved; its
|
||||
remaining three differences are the unchanged count-limit reloads, not a
|
||||
formal proof or an exactness claim.
|
||||
|
||||
Full 43U build succeeds with the approved wrapper and
|
||||
WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
`git diff --check` succeeds. No remote, linking, shared-header, assembly,
|
||||
volatile, register-forcing, dummy-storage or undefined-value changes.
|
||||
99
tools/decomp-assist/allhands-nhttp-stdlib.attempts.md
Normal file
99
tools/decomp-assist/allhands-nhttp-stdlib.attempts.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# NHTTP stdlib source reconstruction, 2026-10-02
|
||||
|
||||
Base `b26e248b`, branch `agent/bittle/nhttp-source-reconstruction`, 43U only.
|
||||
Owned source: `libs/RevoEX/src/nhttp/NHTTP_stdlib_RVL.c`. No headers, metadata,
|
||||
configuration, linking flags, binary data, or other source files changed.
|
||||
The earlier `four-leaves-r9.attempts.md` and other worker logs are untouched.
|
||||
|
||||
## Target-grounded changes
|
||||
|
||||
### NHTTPi_compareToken
|
||||
|
||||
The target enters through its case-folded equality test, then checks the raw left
|
||||
byte for NUL/space before advancing the two pointers. It retains the unsigned
|
||||
byte separately and sign-extends it for both the case fold and termination check.
|
||||
The baseline unconditional loop placed that control-flow boundary differently
|
||||
and compiled to 44 instructions rather than the target's 45.
|
||||
|
||||
The retained while condition captures the raw u8 load and explicitly sign-extends
|
||||
it into LowerCase. The body reuses that captured byte for termination. LowerCase
|
||||
returns its conditional value directly, preserving the target's separate folded
|
||||
value lifetime. This recovers the complete 45-instruction control-flow shape.
|
||||
The common helper's other callers remain unchanged at the instruction level.
|
||||
A separate token-only helper gave the same result; it was removed to avoid
|
||||
unnecessary duplication.
|
||||
|
||||
Remaining differences: two initial constant loads are reversed, and eight
|
||||
instruction operands use different scratch/callee-saved registers. This is not
|
||||
an exact match.
|
||||
|
||||
### NHTTPi_Base64Encode
|
||||
|
||||
The target retains signed length/padding comparisons. The length local is now
|
||||
s32, matching those comparisons without the previous mixed-sign comparisons.
|
||||
Each quartet snapshots its three signed input bytes before writing the output,
|
||||
then combines each later byte's high fragment with the preceding byte's masked
|
||||
low fragment. This expresses the target's byte-load and index dependency
|
||||
structure more closely, preserving the 119-instruction body size.
|
||||
|
||||
The target and existing implementation use signed byte shifts, a NUL-terminated
|
||||
input, and full three-byte reads even for a short final group. This candidate does
|
||||
not broaden the API to arbitrary binary data or repair those original constraints.
|
||||
The repository's caller supplies a separate temporary source and authorization
|
||||
output buffer (`d_nhttp.c`, NHTTP_CreateRequest proxy authorization path).
|
||||
|
||||
## Experiments
|
||||
|
||||
- Recovered the previously logged loop-test/raw-byte/ternary-fold approach rather
|
||||
than repeat register/declaration searches. Local conditional-loop alternatives
|
||||
were measured against the target before retaining the compact while condition.
|
||||
- One exploratory assignment/read condition was found to be unsequenced. It was
|
||||
withdrawn, never behavior-tested, and is not part of the retained source.
|
||||
- Signed/unsigned/raw byte representations and explicit sextet fragments were
|
||||
checked against target load/sign-extension evidence. Signed byte snapshots
|
||||
with the retained index grouping gave the best compact source.
|
||||
- Stream-cursor forms generated identical code and were not retained.
|
||||
- A separate quartet helper improved Base64 only 67.63025 -> 67.79832%; it was
|
||||
discarded as unnecessary source expansion. There is no new helper in the diff.
|
||||
- No declaration/register sweep, inline assembly, use-site volatile, dummy value,
|
||||
padding, compiler-option change, or linking experiment was performed.
|
||||
|
||||
## Verification
|
||||
|
||||
Before -> after:
|
||||
- NHTTPi_compareToken: 54.622223 -> 98.844444% fuzzy; 44 -> 45 instructions against
|
||||
target 45. Final ctxdiff: 10 positional differences.
|
||||
- NHTTPi_Base64Encode: 60.285713 -> 67.63025% fuzzy; 119/119 instructions unchanged.
|
||||
Final ctxdiff: 67 positional differences (baseline 58); aligned objdiff improves
|
||||
despite that positional metric. Exact dependency scheduling remains open.
|
||||
- Unit fuzzy: 87.93594 -> 93.03203%.
|
||||
- Exact functions 11/14, exact code 1388/2248, data 112/112 (100%) and linked status
|
||||
are unchanged. All 11 previously exact functions have ctxdiff diffs 0.
|
||||
- The unchanged strnicmp remains 99.76471%, 51/51 instructions, two constant-order
|
||||
differences. LowerCase's other exact users remain exact.
|
||||
- Pool: the one alphabet string is identical. .data's 65 bytes and .rodata's
|
||||
36 bytes equal the prefixes of their 72-byte/40-byte target sections. Existing
|
||||
trailing target alignment extents are unchanged; no padding was introduced.
|
||||
- Literal-reference audit: 14 functions analyzed, no candidates, skips or errors;
|
||||
zero statically addressed call arguments, so this is not a separate proof of
|
||||
complete data matching.
|
||||
- Full 1027-unit report: zero exact-function/code/data/fuzzy regressions.
|
||||
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
|
||||
`26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
|
||||
Host behavior validation compiles both unchanged production sources (baseline
|
||||
and candidate) with -fsigned-char and fixed-width SDK type shims:
|
||||
- 75,536 compareToken cases: all 65,536 first-byte pairs plus 10,000 seeded
|
||||
multi-byte/case-fold/mismatch cases, against an independent token reference.
|
||||
- 3,033 Base64 cases: known answers, every length 0..1024, and 2,000 seeded ASCII
|
||||
strings up to 4096 bytes, against Python base64. Return length, NUL terminator
|
||||
and a 16-byte output canary are checked. Inputs have readable zero tail bytes
|
||||
for the original full-triplet reads. High-bit/binary inputs are not claimed.
|
||||
|
||||
Private local evidence: `/tmp/nhttp-source-reconstruction/` contains baseline and
|
||||
final reports, all function ctxdiffs, pool/literal audits, full-build.log,
|
||||
validate_nhttp.py, vectors.log, and the rejected local experiments. No retail
|
||||
assembly or binary is included in this commit.
|
||||
|
||||
GATE: validated partial control/data-flow/type reconstruction; no regressions.
|
||||
Exact matching and linking remain open. Frozen for independent parent validation.
|
||||
@@ -127,3 +127,73 @@ The harness is supplemental behavioral validation, not a retail runtime test.
|
||||
|
||||
GATE: focused decompilation improvement; full 43U/DOL and no-regression checks
|
||||
pass; exact-matching gate remains incomplete at 30/31. No linking claimed.
|
||||
|
||||
## Follow-on: recover the last ESMisc structural differences
|
||||
|
||||
Baseline for this follow-on is the accepted reconstruction `1f9db89d`:
|
||||
30/31 exact functions, function 95.830734%, unit 99.33143%, 446/449 instructions,
|
||||
data 4416/4416. The source/header correction remains intact.
|
||||
|
||||
Natural source attempts, in order:
|
||||
|
||||
| Attempt | Instructions | Function fuzzy | Disposition |
|
||||
| --- | ---: | ---: | --- |
|
||||
| Ticket helper uses error-first cleanup and returns early with no tickets | 446/449 | 95.830734% | Same generated code |
|
||||
| Caller gives aligned ticket scratch an explicit pointer lifetime | 448/449 | 98.004456% | Improved |
|
||||
| Move aligned ticket scratch into the ticket helper | 446/449 | 95.817375% | Rejected |
|
||||
| Scope caller's scratch pointer to successful title enumeration | 448/449 | 98.89755% | Retained |
|
||||
| Restore nested ticket helper with scoped scratch | 448/449 | 98.89755% | Same generated code |
|
||||
| Ticket helper returns its actual ES operation status | 449/449 | 99.14254% | Retained |
|
||||
|
||||
The scratch pointer is initialized only in the block reached after successful
|
||||
second enumeration, and remains live across the title loop. This restores the
|
||||
saved scratch cursor and per-iteration 64-bit mask materialization. No pointer
|
||||
is used before initialization and no artificial use extends its lifetime.
|
||||
|
||||
The private ticket helper now returns the status already obtained from
|
||||
ES_GetTicketViews or ES_DeleteTicket, including its zero-ticket early return
|
||||
and normal cleanup. Its caller intentionally discards that status. The return
|
||||
contract of an independently emitted original helper cannot be established
|
||||
because this helper was fully inlined; this is a natural equivalent source
|
||||
form whose zero-ticket branch structure is confirmed by the target. It does
|
||||
not overwrite the outer enumeration status or change the public ABI further.
|
||||
|
||||
Final ctxdiff: 449/449 instructions, 74 differences. Every mnemonic,
|
||||
non-register operand, stack offset, resolved call target and branch target
|
||||
agrees. The remaining differences are register substitutions, including the
|
||||
title list, scratch cursor, title index, verifier flags and title halves. No
|
||||
register/declaration permutation search was performed after reaching this
|
||||
structural agreement.
|
||||
|
||||
Measurements after a fresh full report:
|
||||
|
||||
- ESMisc exact functions 30/31 -> 30/31
|
||||
- ESMisc exact code 9404/11200 -> 9404/11200
|
||||
- ESMisc fuzzy 99.33143% -> 99.8625%
|
||||
- DeleteUnauthorizedData fuzzy 95.830734% -> 99.14254%
|
||||
- Matched data 4416/4416 -> 4416/4416
|
||||
- Pool: all 114 strings identical
|
||||
- Literal audit: 204 arguments in 30 exact functions, no candidates/errors
|
||||
- Every other unit's full report is unchanged
|
||||
- Full 43U build/check and DOL SHA1 pass:
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
- The same 12 ASan/UBSan host control-flow scenarios pass on helper bodies
|
||||
freshly extracted from this final candidate (LeakSanitizer disabled only
|
||||
for the environment limitation already noted)
|
||||
- git diff --check passes
|
||||
|
||||
This remains a partial matching improvement, not an exact function or unit.
|
||||
|
||||
### Rejected ATERM ownership experiment
|
||||
|
||||
Read-only target evidence identified that the old typed reply view spans the
|
||||
last eight bytes of one BSS object and the following option-buffer allocation.
|
||||
With parent approval, tried a real two-object protocol-workspace aggregate and
|
||||
corresponding narrow metadata consolidation. It preserved storage, addresses,
|
||||
all 17 exact functions and matched data, and reduced the main protocol from
|
||||
972 to 959 instructions (target 951). However, its unit fuzzy regressed from
|
||||
96.624664% to 96.49781%; wider grouping and a decoder-helper experiment also
|
||||
failed the no-regression condition. All ATERM source and symbol metadata were
|
||||
restored. Fresh report after restoration was identical to the accepted ESMisc
|
||||
baseline, and the DOL hash passed. Detailed rejected source/metadata and
|
||||
address evidence were kept privately for future work; none is in this commit.
|
||||
|
||||
23
tools/decomp-assist/attempts/iplSetting-worker3-draw.md
Normal file
23
tools/decomp-assist/attempts/iplSetting-worker3-draw.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# iplSetting worker3 — Setting::draw (Oct 2 2026)
|
||||
|
||||
Worktree: `/workspace/worktrees/iplSetting-draw`
|
||||
Branch: `agent/grok/decomp-worker-3/draw`
|
||||
Unit: `src/scene/setting/iplSetting.cpp` `Setting::draw` only.
|
||||
`scanAP` / `convertRevIP` source not touched. File stays `NonMatching` (not linked).
|
||||
|
||||
## Result
|
||||
|
||||
**632/632 byte-identical** to retail (`draw__Q33ipl5scene7SettingFv`, 2528 bytes, 0 diffs).
|
||||
A HEAD compile of the same TU differs from this object only in `draw`. No sibling codegen change (`-ipa file`).
|
||||
|
||||
## Levers that closed it
|
||||
|
||||
1. `wideTopL` / `wideTopR` as separate locals (no CSE of the int-to-float). Gets `xoris r6,r6` and `fsubs f2`.
|
||||
2. One `void* held` is the browser thread, then overwritten by the standard-buffer fetch, so browser and `standardBuffer` share r31.
|
||||
3. Tex0 material pointer reused as the scroll `FrameController*` (`wideMaterial`), with `initFrame`/`restart` duplicated in each arm.
|
||||
4. Field copy through `volatile GXRenderModeObj*` so loads and stores interleave on r4/r0.
|
||||
5. Sample-pattern loop is direct `dst[1]=src[1]; dst[2]=src[2]` with `src` declared before `dst` is assigned (`u8* src; u8* dst = ...; src = ...`).
|
||||
|
||||
## Not linked
|
||||
|
||||
`configure.py` still has `Object(NonMatching, "scene/setting/iplSetting.cpp")`. DOL SHA1 is unchanged because this TU is not linked. Do not flip the object to Matching until `scanAP` / `convertRevIP` (and the rest of the TU) match.
|
||||
@@ -16,3 +16,11 @@ Claim was only `cdj_d_decompressLoop`. colorConv, huffmanDecoder, and LineConv11
|
||||
- 2x2 tail stores the updated plane in `requiredBlockEnd` and the end pointer in `planeOffset`. That is what puts the plane in r15 and the end in r16 (`addi r15, r3, -8` / `add r16, r15, r18`). Assigning the plane back to `planeOffset` left those two callee-saves swapped (7 diffs). Splitting the `-8` let MWCC cancel it against the later `+8` and dropped to 897.
|
||||
|
||||
colorConv left at the 18 pairwise wall. Not in this diff.
|
||||
|
||||
## colorConv (2026-10-02)
|
||||
|
||||
`cdj_c_colorConv` **77/77, 0 diffs, byte-identical** (308 bytes). Was 18, then 13, then 8.
|
||||
|
||||
- Drop `paddedWidth`. The row loop adds `paddedDimensions[0]`, which hoists `lhz r24` and `lis r23` / `addi r10, r23, 0`.
|
||||
- Pad loop: `u16 remainder = dimensions[i] & 7`, then `(dimensions[i] + 8) - remainder`. Width stays r8, the indexed load stays r7, the mask stays r9. Naming both a dimension and a remainder swaps width off r8.
|
||||
- Declare `sourceStride` after `rowIndex` (cb/cr stay above it). That assigns stride r29 and `cbPlane` r22. Computing stride before the planes shortens the function to 76 and shifts the callee-saves. huffmanDecoder and LineConv11 were not edited. `cdj_d_decompressLoop` stays 899/899.
|
||||
|
||||
244
tools/decomp-assist/jpeg-exif-allhands-attempts.md
Normal file
244
tools/decomp-assist/jpeg-exif-allhands-attempts.md
Normal file
@@ -0,0 +1,244 @@
|
||||
# EXIF parser reconstruction and aliasing audit
|
||||
|
||||
Base: `2a33684c` on `agent/bittle/allhands-jpeg-decompile`; EXIF source itself is
|
||||
unchanged from baseline `449529d9`. This is a separate candidate from the prior
|
||||
JPEG converter/IDCT commit. Those files and their logs were left unchanged.
|
||||
|
||||
## Retained reconstruction
|
||||
|
||||
1. The IFD0 entry parameter is `u8*`, with corresponding call-site casts from the
|
||||
parser's read-only directory cursor. With the reconstructed `const u8*`
|
||||
parameter, MWCC hoists all four version-byte loads before their stores.
|
||||
Removing this unsupported qualifier reproduces the original interleaved
|
||||
load/store sequence for tags 0x9000, 0x9101 and 0xA000.
|
||||
2. IFD0's decoded field type is widened to `u32` and both entry fields use the
|
||||
existing `readExifU16` reader. This reproduces the target's eager zero
|
||||
extension and initial instruction order; it does not change TIFF field size.
|
||||
3. IFD1 explicitly includes ignored 0x011C and 0xA000..0xA002 cases alongside
|
||||
existing ignored tags. Target dispatch compares against 0x011C and 0xA004;
|
||||
these case labels improve the recovered decision tree. The precise original
|
||||
no-op case list cannot be proved uniquely, since unknown tags also return
|
||||
unchanged. No new tag interpretation or payload write is introduced.
|
||||
4. IFD1 rational denominators use `thumbnailData + (offset + 4)` without a
|
||||
redundant same-type cast.
|
||||
|
||||
No new exact functions. Exact stays 3/6, matched code 1348/5088 bytes, allocated
|
||||
data 0 bytes / 100%, and linking is unchanged. Unit fuzzy 96.50157 -> 98.94104.
|
||||
|
||||
| Function | Before | After | Source/target instructions |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| TMCCJPEGDecGetOffsetEXIF | 100 | 100 | 155/155, ctxdiff 0 |
|
||||
| TMCCJPEGDecGetInfoEXIF | 100 | 100 | 132/132, ctxdiff 0 |
|
||||
| TMCJPEGDEC_exif_parse | 99.43396 | 99.43396 | 212/212 |
|
||||
| TMCJPEGDEC_IFD0_tag_parse | 94.46986 | 99.386696 | 480/481 |
|
||||
| TMCJPEGDEC_IFD1_tag_parse | 93.099174 | 96.14876 | 239/242 |
|
||||
| TMCJPEGDEC_ThumbnailCheck | 100 | 100 | 50/50, ctxdiff 0 |
|
||||
|
||||
IFD0 still lacks the original low-tag `bltlr` leaf. Aligning that instruction and
|
||||
its branch displacements leaves 32 GPR-operand differences in the two rational
|
||||
field cases. IFD1 still has decision-tree and register differences. The parser
|
||||
retains 21 GPR-operand differences. Nothing here claims exact completion.
|
||||
|
||||
## Concrete behavioral distinction
|
||||
|
||||
An internal IFD0 entry can be arranged with its four version bytes overlapping
|
||||
the destination by one byte. Initial source bytes 01 02 03 04 produce:
|
||||
|
||||
- Baseline compiled code: destination 01 02 03 04
|
||||
- Original object: destination 01 01 01 01
|
||||
- Corrected compiled code: destination 01 01 01 01
|
||||
|
||||
This is evidence about the internal parser's byte-copy/aliasing behavior. It is
|
||||
not a claim that ordinary nonoverlapping EXIF input was decoded incorrectly, or
|
||||
that a public API vulnerability has been established. Both byte orders and all
|
||||
three version fields were checked at offsets -3 through +3, giving 42 overlap
|
||||
cases. The unchanged baseline object fails this regression test; the final
|
||||
object passes all 42. Local destination casts, explicit loops and removal of
|
||||
other const qualifiers did not fix the discrepancy and were restored.
|
||||
|
||||
## Validation
|
||||
|
||||
- Pool checked before tuning and after the final build: identical, zero strings
|
||||
- No allocated non-code sections in either EXIF object
|
||||
- Fresh official report: all six function scores compared with baseline,
|
||||
zero regressions; all three exact functions retain ctxdiff zero differences
|
||||
- Full 4.3U build: PASS
|
||||
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`
|
||||
- `git diff --check 2a33684c`: PASS, including the committed candidate diff
|
||||
- No header/configuration/linking edits, no changes to the separately owned
|
||||
entropy decoder, no remote writes or original binary data committed
|
||||
|
||||
Build/report commands:
|
||||
|
||||
```sh
|
||||
python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo
|
||||
WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja
|
||||
build/tools/objdiff-cli report generate -p . -o build/43U/report.json -f json
|
||||
PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/pool_diff.py build/43U/src/libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse.o build/43U/obj/libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse.o
|
||||
PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/ctxdiff.py libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse <symbol>
|
||||
../.venv/bin/python tools/decomp-assist/jpeg_exif_differential_audit.py
|
||||
../.venv/bin/python tools/decomp-assist/jpeg_exif_differential_audit.py --overlap-only
|
||||
```
|
||||
|
||||
## Differential test scope
|
||||
|
||||
`jpeg_exif_differential_audit.py` is a read-only bounded integer PPC interpreter
|
||||
and deterministic test generator. It reads local ELF objects and never writes
|
||||
original executable bytes to the repository. It is a separate test tool; the
|
||||
previous converter/IDCT audit remains unchanged.
|
||||
|
||||
- 267,282 paired calls, seed 449529
|
||||
- Every 16-bit tag selector in both byte orders for both IFD handlers
|
||||
- Field types 0, 3, 4 and 0xFFFF; valid, boundary, out-of-range and wrapping
|
||||
offsets for supported scalar/rational/byte-array tags
|
||||
- Header sizes and offsets, valid/invalid byte order and TIFF magic, truncated
|
||||
entry arrays, IFD0/IFD1/Exif-directory chains and directory-boundary lengths
|
||||
- 42 overlapping version-byte cases that distinguish baseline from original
|
||||
- Every non-stack byte compared, including guard regions; parser return values,
|
||||
stack pointer, LR and GPR14..GPR31 preservation checked
|
||||
- Complete instruction-address coverage of IFD0 and the central parser in both
|
||||
objects; IFD1 covers every source instruction and 241/242 target instructions
|
||||
(one unreachable return in the target dispatch is not visited)
|
||||
|
||||
Limitations: this is not formal equivalence or a Wii runtime test. Instruction
|
||||
coverage is not exhaustive path/input coverage. The custom interpreter models
|
||||
only the observed integer subset, condition comparisons and internal EXIF calls;
|
||||
unsupported instructions/relocations/callees fail closed. FPU, XER overflow,
|
||||
exceptions, timing, cache/MMIO and a full system ABI are not modeled. Relocations
|
||||
use collision-checked symbol tokens; actual linked addresses are not tested.
|
||||
Public JPEG I/O, thumbnail decoding, arbitrary pointer values and all possible
|
||||
payload alias layouts are outside this test. The three exact wrappers are
|
||||
checked by objdiff/ctxdiff rather than executing their external dependencies.
|
||||
|
||||
Run from the repository root with pyelftools and Capstone available, and without
|
||||
Python's `-O` option. `--source-object` and `--target-object` can select separately
|
||||
compiled objects, allowing the overlap regression to be reproduced on baseline
|
||||
without changing the working tree. Final output is in
|
||||
`jpeg-exif-allhands-differential-results.txt`.
|
||||
|
||||
## Existing external branch overlap
|
||||
|
||||
Read-only comparison used the already fetched ref
|
||||
`origin/agent/w1009/tmc` at `cd90be696cb86258a1bc9fb9dc2b304f2bed318d`.
|
||||
No fetch, author communication, branch checkout or merge was performed.
|
||||
|
||||
Its `1c7cf40c` independently removes const from both tag-entry parameters, so the
|
||||
central IFD0 qualifier correction overlaps. Its `81440c32` then uses a u16 tag,
|
||||
u16 type and explicit tag remask. Its no-op case ranges differ from this
|
||||
candidate's explicit ignored tags. It also changes the shared 16-bit reader and
|
||||
parser declaration order. This candidate does not contain those changes.
|
||||
|
||||
An isolated `/tmp` compile of that branch's EXIF source, using the current
|
||||
checkout's original MWCC flags, produced:
|
||||
|
||||
| Measure/function | This candidate | cd90be69 EXIF object |
|
||||
| --- | ---: | ---: |
|
||||
| Unit fuzzy | 98.94104 | 99.01337 |
|
||||
| Central parser | 99.43396 | 98.679245 |
|
||||
| IFD0 | 99.386696 | 98.37838 |
|
||||
| IFD1 | 96.14876 | 99.194214 |
|
||||
| Exact functions | 3/6 | 3/6 |
|
||||
|
||||
Neither candidate wholly supersedes the other. This candidate has the better
|
||||
IFD0 and preserves the current parser score; the external candidate has the
|
||||
better IFD1. Integration must preserve the parser score and independently
|
||||
revalidate any combined source. The isolated comparison is not a full gate of
|
||||
the external branch or its other files.
|
||||
|
||||
Relative to baseline 449529d9, the external RGB565 edits concern its setter and
|
||||
do not overlap the prior candidate's RGB444 body. Its RGBA420 edge edits overlap
|
||||
that prior candidate's changed expression context. It does not change IDCT.
|
||||
The previously committed JPEG candidate remains separate and unchanged.
|
||||
|
||||
## Attempts
|
||||
|
||||
All rejected/equal variants were restored. The lower-tag 0x0100 experiment had a
|
||||
fuzzy improvement but was explicitly discarded after review: the original
|
||||
branch shape does not establish that particular no-op label, and it changed
|
||||
other lower dispatch comparisons. It is absent from the final source.
|
||||
|
||||
### trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse word-width-field-type: 94.469860 -> 95.122660; RETAIN
|
||||
TMCJPEGDEC_IFD0_tag_parse explicit-ignored-compression-return: 95.122660 -> 94.914764; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse explicit-ignored-compression-break: 95.122660 -> 95.122660; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse recognized-ignored-planar-and-pixel-tags: 93.099174 -> 95.942150; RETAIN
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-low-strip-offset-own-return: 95.942150 -> 95.342970; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-orientation-own-return: 95.942150 -> 95.533060; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-datetime-own-return: 95.942150 -> 95.528920; restore
|
||||
```
|
||||
|
||||
### control-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse explicit-unknown-tag-return: 95.122660 -> 94.498960; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse explicit-unknown-tag-break: 95.122660 -> 95.122660; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse explicit-unknown-tag-return: 95.942150 -> 95.876030; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse explicit-unknown-tag-break: 95.942150 -> 95.942150; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ifd1-orientation-uses-unknown-exit: 95.942150 -> 95.756195; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ifd1-planar-uses-unknown-exit: 95.942150 -> 91.694214; restore
|
||||
```
|
||||
|
||||
### ignored-tag-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-image-fields-before-compression: 95.122660 -> 95.110180; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-image-fields: 95.942150 -> 95.735535; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ifd1-planar-logical-case-order: 95.942150 -> 95.942150; restore
|
||||
```
|
||||
|
||||
### reader-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse shared-exif-tag-reader: 95.122660 -> 95.195430; RETAIN
|
||||
TMCJPEGDEC_IFD0_tag_parse shared-exif-type-reader: 95.195430 -> 95.517670; RETAIN
|
||||
TMCJPEGDEC_IFD0_tag_parse shared-exif-short-reader: 95.517670 -> 95.517670; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse shared-exif-tag-reader: 95.942150 -> 95.942150; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse shared-exif-short-reader: 95.942150 -> 95.942150; restore
|
||||
```
|
||||
|
||||
### lower-tag-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(256,): 95.517670 -> 93.004160; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(257,): 95.517670 -> 93.004160; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(258,): 95.517670 -> 95.505196; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(256, 257): 95.517670 -> 93.004160; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(256, 258): 95.517670 -> 93.004160; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(257, 258): 95.517670 -> 95.505196; restore
|
||||
TMCJPEGDEC_IFD0_tag_parse ignored-lower-tags-(256, 257, 258): 95.517670 -> 95.505196; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(256,): 95.942150 -> 96.665290; RETAIN
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(257,): 96.665290 -> 96.665290; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(258,): 96.665290 -> 95.735535; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(256, 257): 96.665290 -> 96.644630; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(256, 258): 96.665290 -> 96.256195; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(257, 258): 96.665290 -> 95.735535; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse ignored-lower-tags-(256, 257, 258): 96.665290 -> 95.735535; restore
|
||||
```
|
||||
|
||||
### byte-copy-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse alias-preserving-version-byte-copy: 95.517670 -> 95.517670; restore
|
||||
```
|
||||
|
||||
### version-loop-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse forward-version-byte-loops: 95.517670 -> 95.517670; restore
|
||||
```
|
||||
|
||||
### qualifier-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD0_tag_parse mutable-entry-view: 95.517670 -> 99.386696; RETAIN
|
||||
TMCJPEGDEC_IFD1_tag_parse mutable-entry-view: 95.942150 -> 95.942150; restore
|
||||
```
|
||||
|
||||
### pointer-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IFD1_tag_parse mutable-rational-byte-view: 95.942150 -> 95.942150; restore
|
||||
TMCJPEGDEC_IFD1_tag_parse direct-denominator-byte-address: 95.942150 -> 96.148760; RETAIN
|
||||
```
|
||||
@@ -0,0 +1,6 @@
|
||||
TMCJPEGDEC_IFD0_tag_parse 131072 selector cases PASS
|
||||
TMCJPEGDEC_IFD1_tag_parse 131072 selector cases PASS
|
||||
TMCJPEGDEC_IFD0_tag_parse 132746 cases PASS; own-body instruction coverage 480 / 480 source; 481 / 481 original
|
||||
TMCJPEGDEC_IFD1_tag_parse 132704 cases PASS; own-body instruction coverage 239 / 239 source; 241 / 242 original
|
||||
TMCJPEGDEC_exif_parse 1832 cases PASS; own-body instruction coverage 212 / 212 source; 212 / 212 original
|
||||
TOTAL 267282 paired EXIF calls PASS
|
||||
82
tools/decomp-assist/jpeg-next-reconstruction-attempts.md
Normal file
82
tools/decomp-assist/jpeg-next-reconstruction-attempts.md
Normal file
@@ -0,0 +1,82 @@
|
||||
# JPEG follow-on reconstruction
|
||||
|
||||
Base: `813660b9`, branch `agent/bittle/jpeg-reconstruction-next`.
|
||||
The already-reviewed EXIF candidate `b9305280` was preserved unchanged as local
|
||||
cherry-pick `164dbbc5`. This log concerns a separate follow-on to that candidate.
|
||||
|
||||
## Retained change
|
||||
|
||||
IFD0 rational denominator addresses now use the same explicit offset grouping as
|
||||
IFD1: add four to the TIFF offset, then add the thumbnail-data base. The redundant
|
||||
same-type pointer cast is removed. This is a two-line source change; it introduces
|
||||
no new tag interpretation, new memory access, or function.
|
||||
|
||||
- `TMCJPEGDEC_IFD0_tag_parse`: 99.386696 -> 99.49065 fuzzy
|
||||
- EXIF unit: 98.94104 -> 98.98035 fuzzy
|
||||
- EXIF exact functions: 3/6 -> 3/6; matched code remains 1348/5088 bytes
|
||||
- IFD0 remains 480/481 instructions; this is not an exact match or linking result
|
||||
- All other 33 owned functions retain their baseline scores
|
||||
|
||||
No changes are retained in the color converters or IDCT. No declaration-order
|
||||
search, forced registers, volatile, assembly, padding, headers, configuration,
|
||||
linking changes, remote writes, or edits to the entropy decoder were made.
|
||||
|
||||
## Rejected reconstruction trials
|
||||
|
||||
Every equal or regressing trial was restored before validation.
|
||||
|
||||
- Separate rational numerator/denominator pointer lifetimes in IFD0 and IFD1:
|
||||
unchanged from the retained expression; restored
|
||||
- RGB444's common edge-sibling channel evaluation and clipping order with a
|
||||
separate luminance value: 98.71429 -> 98.62637; restored
|
||||
- Explicit odd-coefficient differences in the luminance second-pass butterfly:
|
||||
83.05058 -> 81.42802; restored
|
||||
- Extract the luminance first-pass row transform to a static inline helper:
|
||||
83.05058 -> 81.12062; restored. The trial script initially omitted helper
|
||||
local declarations, causing a compiler error; that experiment was corrected,
|
||||
measured, and then fully restored
|
||||
- Extract RGBA pixel packing to a static inline helper:
|
||||
- 411: 82.6033 -> 81.72314; restored
|
||||
- 422 and edge: unchanged at 87.72298 and 90.08849; restored
|
||||
- 420 and edge: unchanged at 89.40523 and 87.458336; restored
|
||||
- 211 and edge: unchanged at 91.15385 and 92.0; restored
|
||||
- 444: unchanged at 90.670105; restored
|
||||
- 444 edge: 88.90909 -> 87.70909; restored
|
||||
|
||||
These were source-structure trials, not permutations of register declarations.
|
||||
The source-neutral scheduling differences that remain were not chased through
|
||||
artificial source changes.
|
||||
|
||||
## Verification
|
||||
|
||||
The baseline report was generated after building the unchanged cherry-picked
|
||||
candidate. The final report was freshly generated after restoring every rejected
|
||||
trial and rebuilding all four owned objects.
|
||||
|
||||
- Full 4.3U build: PASS
|
||||
- All 34 owned function scores compared against the baseline: zero regressions
|
||||
- All 11 previously exact functions retain exact-name objdiff 100 and ctxdiff 0
|
||||
- Pool checks before trials and after the final build: all four identical,
|
||||
zero strings
|
||||
- Neither source nor original object has allocated non-code sections in any of
|
||||
the four owned units
|
||||
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`
|
||||
- The existing read-only bounded PPC audit tools were inspected before use;
|
||||
their scripts are unchanged
|
||||
- Converter/IDCT audit: all 9,456 paired calls pass
|
||||
|
||||
- EXIF audit: all 267,282 paired calls pass, including the 42 version-byte
|
||||
overlap cases preserved by the preceding candidate
|
||||
- `git diff --check 813660b9`: PASS, including the base-relative committed diff
|
||||
- The working tree is paused for parent review after the focused local commit
|
||||
These interpreter tests are bounded samples, not formal equivalence or Wii
|
||||
runtime tests. Their existing coverage and modeling limitations still apply.
|
||||
|
||||
## Existing external overlap
|
||||
|
||||
The prior EXIF log documents the already fetched
|
||||
`origin/agent/w1009/tmc` branch's overlap with EXIF and color reconstruction.
|
||||
That overlap remains relevant to parent integration. This follow-on was derived
|
||||
from the current source, the prior owned reconstruction, and local object
|
||||
comparisons. No external branch was merged, copied, fetched, or contacted.
|
||||
The parent should preserve the previously queued EXIF candidate separately.
|
||||
63
tools/decomp-assist/jpeg-next-reconstruction-validation.txt
Normal file
63
tools/decomp-assist/jpeg-next-reconstruction-validation.txt
Normal file
@@ -0,0 +1,63 @@
|
||||
main/libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var 89.06892 -> 89.06892
|
||||
POOL IDENTICAL up to 0 (mine=0 base=0)
|
||||
No allocated non-code sections in either object
|
||||
main/libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse 98.94104 -> 98.98035
|
||||
POOL IDENTICAL up to 0 (mine=0 base=0)
|
||||
TMCCJPEGDecGetOffsetEXIF: src 0x26c base 0x26c insns 155/155; diffs 0: []
|
||||
TMCCJPEGDecGetInfoEXIF: src 0x210 base 0x210 insns 132/132; diffs 0: []
|
||||
TMCJPEGDEC_IFD0_tag_parse 99.386696 -> 99.49065
|
||||
TMCJPEGDEC_ThumbnailCheck: src 0xc8 base 0xc8 insns 50/50; diffs 0: []
|
||||
No allocated non-code sections in either object
|
||||
main/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565 96.44502 -> 96.44502
|
||||
POOL IDENTICAL up to 0 (mine=0 base=0)
|
||||
TMCJPEGDEC_converterYUV422toRGB565edge: src 0x1ac base 0x1ac insns 107/107; diffs 0: []
|
||||
TMCJPEGDEC_converterYUV211toRGB565: src 0x188 base 0x188 insns 98/98; diffs 0: []
|
||||
TMCJPEGDEC_converterYUV211toRGB565edge: src 0x1b4 base 0x1b4 insns 109/109; diffs 0: []
|
||||
TMCJPEGDEC_converterYUV444toRGB565edge: src 0x1a0 base 0x1a0 insns 104/104; diffs 0: []
|
||||
TMCJPEGDEC_converterYUV400toRGB565: src 0x118 base 0x118 insns 70/70; diffs 0: []
|
||||
TMCJPEGDEC_converterYUV400toRGB565edge: src 0x14c base 0x14c insns 83/83; diffs 0: []
|
||||
No allocated non-code sections in either object
|
||||
main/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGBA8 90.32323 -> 90.32323
|
||||
POOL IDENTICAL up to 0 (mine=0 base=0)
|
||||
TMCJPEGDEC_converterYUV400toRGBA8: src 0x130 base 0x130 insns 76/76; diffs 0: []
|
||||
TMCJPEGDEC_converterYUV400toRGBA8edge: src 0x164 base 0x164 insns 89/89; diffs 0: []
|
||||
No allocated non-code sections in either object
|
||||
34 owned function scores checked; 11 exact functions preserved; zero regressions
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d build/43U/main.dol
|
||||
|
||||
TMCJPEGDEC_IFD0_tag_parse 131072 selector cases PASS
|
||||
TMCJPEGDEC_IFD1_tag_parse 131072 selector cases PASS
|
||||
TMCJPEGDEC_IFD0_tag_parse 132746 cases PASS; own-body instruction coverage 480 / 480 source; 481 / 481 original
|
||||
TMCJPEGDEC_IFD1_tag_parse 132704 cases PASS; own-body instruction coverage 239 / 239 source; 241 / 242 original
|
||||
TMCJPEGDEC_exif_parse 1832 cases PASS; own-body instruction coverage 212 / 212 source; 212 / 212 original
|
||||
TOTAL 267282 paired EXIF calls PASS
|
||||
|
||||
TMCJPEGDEC_converterYUV411toRGBA8: 100 cases PASS; instruction coverage source 242/242, original 242/242
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge: 400 cases PASS; instruction coverage source 112/112, original 112/112
|
||||
TMCJPEGDEC_converterYUV422toRGBA8: 100 cases PASS; instruction coverage source 148/148, original 148/148
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge: 400 cases PASS; instruction coverage source 113/113, original 113/113
|
||||
TMCJPEGDEC_converterYUV420toRGBA8: 100 cases PASS; instruction coverage source 153/153, original 153/153
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge: 400 cases PASS; instruction coverage source 120/120, original 120/120
|
||||
TMCJPEGDEC_converterYUV211toRGBA8: 100 cases PASS; instruction coverage source 104/104, original 104/104
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge: 400 cases PASS; instruction coverage source 115/115, original 115/115
|
||||
TMCJPEGDEC_converterYUV444toRGBA8: 100 cases PASS; instruction coverage source 97/97, original 97/97
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge: 400 cases PASS; instruction coverage source 110/110, original 110/110
|
||||
TMCJPEGDEC_converterYUV400toRGBA8: 100 cases PASS; instruction coverage source 57/76, original 57/76
|
||||
TMCJPEGDEC_converterYUV400toRGBA8edge: 400 cases PASS; instruction coverage source 70/89, original 70/89
|
||||
TMCJPEGDEC_set_converterRGBA8: 1024 cases PASS; instruction coverage source 168/169, original 169/170
|
||||
TMCJPEGDEC_converterYUV411toRGB565: 100 cases PASS; instruction coverage source 217/217, original 217/217
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge: 400 cases PASS; instruction coverage source 106/106, original 106/106
|
||||
TMCJPEGDEC_converterYUV422toRGB565: 100 cases PASS; instruction coverage source 136/136, original 136/136
|
||||
TMCJPEGDEC_converterYUV422toRGB565edge: 400 cases PASS; instruction coverage source 107/107, original 107/107
|
||||
TMCJPEGDEC_converterYUV420toRGB565: 100 cases PASS; instruction coverage source 141/141, original 141/141
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge: 400 cases PASS; instruction coverage source 114/114, original 114/114
|
||||
TMCJPEGDEC_converterYUV211toRGB565: 100 cases PASS; instruction coverage source 98/98, original 98/98
|
||||
TMCJPEGDEC_converterYUV211toRGB565edge: 400 cases PASS; instruction coverage source 109/109, original 109/109
|
||||
TMCJPEGDEC_converterYUV444toRGB565: 100 cases PASS; instruction coverage source 91/91, original 91/91
|
||||
TMCJPEGDEC_converterYUV444toRGB565edge: 400 cases PASS; instruction coverage source 104/104, original 104/104
|
||||
TMCJPEGDEC_converterYUV400toRGB565: 100 cases PASS; instruction coverage source 51/70, original 51/70
|
||||
TMCJPEGDEC_converterYUV400toRGB565edge: 400 cases PASS; instruction coverage source 64/83, original 64/83
|
||||
TMCJPEGDEC_set_converterRGB565: 1024 cases PASS; instruction coverage source 168/169, original 169/170
|
||||
TMCJPEGDEC_IdctBlock_Lumi: 704 cases PASS; instruction coverage source 257/257, original 257/257
|
||||
TMCJPEGDEC_IdctBlock_Col: 704 cases PASS; instruction coverage source 454/454, original 454/454
|
||||
TOTAL: 9456 differential cases PASS; GPR14-GPR31, stack pointer and LR preserved
|
||||
276
tools/decomp-assist/jpeg-remainder-attempts.md
Normal file
276
tools/decomp-assist/jpeg-remainder-attempts.md
Normal file
@@ -0,0 +1,276 @@
|
||||
# JPEG remainder: semantic audit and source-shape reconstruction
|
||||
|
||||
Baseline: `449529d9`, branch `agent/bittle/allhands-jpeg-decompile`, 4.3U only.
|
||||
No remote writes, header changes, configuration changes, linking changes, assembly,
|
||||
volatile forcing, padding, or edits to the separately owned entropy decoder.
|
||||
|
||||
## Result
|
||||
|
||||
All 28 owned functions were already implemented. No semantic mismatch was found
|
||||
in a bounded differential comparison of their current compiled PPC against their
|
||||
original ELF function bodies. This is additional test evidence, not a formal
|
||||
proof of equivalence and not a Wii runtime test.
|
||||
|
||||
Three natural source-shape changes improved the report without a function-score
|
||||
regression:
|
||||
|
||||
- Luminance IDCT now uses explicit odd-coefficient sum/difference temporaries,
|
||||
matching the existing chroma first-pass butterfly. Function fuzzy
|
||||
82.31518 -> 83.05058; 257/257 instructions, 187 ctxdiff differences remain
|
||||
- RGB444 consumes the luminance temporary as the red channel and uses the
|
||||
existing exact edge sibling's red/green packing association. Function fuzzy
|
||||
97.96703 -> 98.71429; 91/91 instructions, 13 ctxdiff differences remain
|
||||
- RGBA420 edge consumes the luminance temporary as red after calculating the
|
||||
other channels. Function fuzzy 87.4 -> 87.458336; 120/120 instructions,
|
||||
77 ctxdiff differences remain
|
||||
|
||||
No new exact matches. This candidate is not an exact-matching or linking result.
|
||||
|
||||
| Unit | Exact before -> after | Fuzzy before -> after | Allocated data |
|
||||
| --- | --- | --- | --- |
|
||||
| Texture_MCUtoRGBA8 | 2/13 -> 2/13 | 90.318985 -> 90.32323 | 0 bytes; 100% |
|
||||
| Texture_MCUtoRGB565 | 6/13 -> 6/13 | 96.40103 -> 96.44502 | 0 bytes; 100% |
|
||||
| idct_block_var | 0/2 -> 0/2 | 88.80309 -> 89.06892 | 0 bytes; 100% |
|
||||
|
||||
All eight previously exact functions still have exact-name objdiff 100% and
|
||||
ctxdiff zero differences. Each setter remains 169/170 instructions, with one
|
||||
folded buffer-base address operation; the other 26 functions retain their
|
||||
original instruction counts. Every owned function and both input objects were
|
||||
checked for allocated non-code sections: none. Pool checks were run before tuning and after the final build; all three were
|
||||
identical, with zero strings.
|
||||
|
||||
The baseline comparison was regenerated by rebuilding saved unmodified versions
|
||||
of the three owned sources, reporting them, then restoring/rebuilding the final
|
||||
sources. All 28 function scores were compared; zero regressions.
|
||||
|
||||
Full build: PASS. `git diff --check`: PASS.
|
||||
DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
|
||||
Commands used:
|
||||
|
||||
```sh
|
||||
python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo
|
||||
WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja
|
||||
build/tools/objdiff-cli report generate -p . -o build/43U/report.json -f json
|
||||
PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/pool_diff.py <source-object> <original-object>
|
||||
PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/ctxdiff.py <unit> <symbol>
|
||||
../.venv/bin/python tools/decomp-assist/jpeg_differential_audit.py
|
||||
sha1sum build/43U/main.dol
|
||||
```
|
||||
|
||||
## Differential test scope and limitations
|
||||
|
||||
The committed `jpeg_differential_audit.py` is a bounded integer PPC interpreter
|
||||
and deterministic test generator. It reads the locally available source/original
|
||||
ELF objects and does not distribute original executable bytes. Capstone and
|
||||
pyelftools are required. Run it from the repository root after building the
|
||||
three objects; do not run Python with assertions disabled.
|
||||
|
||||
- 9,456 paired calls across all 28 functions, seed 449529
|
||||
- Normal and edge converters: scales 1, 2, 4, 8; multiple MCU origins; both
|
||||
edge-dimension branches; zero, partial and full extents; constant and random
|
||||
luminance/chroma bytes, including negative signed chroma and clipping
|
||||
- Setters: all 256 component selectors and four supported IDCT sizes;
|
||||
randomized 16-bit image dimensions; return values, converter identities and
|
||||
non-stack side effects compared
|
||||
- IDCT: all row extents 1..8 and column-mode representatives 1, 2, 3, 8;
|
||||
DC-only, sparse and dense coefficients; positive/negative coefficients and
|
||||
clipping-boundary DC values; pitches 8, 16, 32
|
||||
- Every non-stack byte is compared, including guard regions, along with setter
|
||||
return values. Stack pointer, LR and GPR14..GPR31 restoration are checked
|
||||
- Full instruction-address coverage was reached for all 20 non-grayscale
|
||||
converter bodies and both IDCT functions. This does not mean exhaustive
|
||||
branch/path/input coverage. Four grayscale bodies retain 19 unvisited
|
||||
instructions each in saturation paths that follow an unsigned byte load;
|
||||
each setter has one unvisited negative-selector branch instruction
|
||||
- Function address relocations are normalized to deterministic symbol tokens,
|
||||
with collision checks. Real linked addresses and integration are not tested
|
||||
- Only the observed integer instruction subset is implemented. Unsupported
|
||||
instructions/relocations/callees fail closed. No FPU, exceptions, cache/MMIO,
|
||||
timing, alignment faults, XER behavior or complete condition-register model
|
||||
- `memset` is modeled by its memory effects and ABI-permitted volatile-register
|
||||
clobbers; its actual library machine code is not executed
|
||||
- Inputs are bounded samples. Invalid pointers, zero scale, arbitrary invalid
|
||||
IDCT descriptors, all 32-bit coefficient patterns, concurrency, real JPEG
|
||||
streams and other units are not covered
|
||||
- This custom interpreter is itself test tooling rather than a formally verified
|
||||
CPU implementation. Official objdiff, ctxdiff and full-DOL checks remain the
|
||||
matching/integration authority
|
||||
|
||||
Exact run output is preserved in `jpeg-remainder-differential-results.txt`.
|
||||
|
||||
## Attempts
|
||||
|
||||
Only strictly improved candidates without other function regressions were kept.
|
||||
No declaration-order permutation search was performed. Failed/equal candidates
|
||||
were restored. The one temporary compile error in the luminance-consumption
|
||||
script was a duplicate local declaration; it was corrected and no broken
|
||||
candidate was retained.
|
||||
|
||||
### type-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_converterYUV411toRGBA8 signed-chroma-pointers: 82.603300 -> 82.500000; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8 signed-chroma-coefficients: 82.603300 -> 82.603300; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8 signed-chroma-domain: 82.603300 -> 81.570250; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge signed-chroma-pointers: 93.883930 -> 91.964290; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge signed-chroma-coefficients: 93.883930 -> 93.750000; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge signed-chroma-domain: 93.883930 -> 92.187500; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8 signed-chroma-pointers: 87.722980 -> 87.722980; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8 signed-chroma-coefficients: 87.722980 -> 87.722980; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8 signed-chroma-domain: 87.722980 -> 87.722980; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8 byte-luminance: 87.722980 -> 87.689186; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge signed-chroma-pointers: 90.088490 -> 90.088490; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge signed-chroma-coefficients: 90.088490 -> 90.088490; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge signed-chroma-domain: 90.088490 -> 88.628320; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge byte-luminance: 90.088490 -> 90.088490; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8 signed-chroma-pointers: 89.405230 -> 89.176470; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8 signed-chroma-coefficients: 89.405230 -> 89.307190; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8 signed-chroma-domain: 89.405230 -> 86.464050; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8 byte-luminance: 89.405230 -> 87.379080; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge signed-chroma-pointers: 87.400000 -> 80.666664; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge signed-chroma-domain: 87.400000 -> 80.666664; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 signed-chroma-pointers: 91.153850 -> 91.153850; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 signed-chroma-coefficients: 91.153850 -> 91.153850; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 signed-chroma-domain: 91.153850 -> 91.153850; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 byte-luminance: 91.153850 -> 91.153850; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge signed-chroma-pointers: 92.000000 -> 91.869570; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge signed-chroma-coefficients: 92.000000 -> 91.869570; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge signed-chroma-domain: 92.000000 -> 91.869570; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 signed-chroma-pointers: 90.670105 -> 90.515465; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 signed-chroma-coefficients: 90.670105 -> 90.515465; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 signed-chroma-domain: 90.670105 -> 90.618550; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 byte-luminance: 90.670105 -> 90.670105; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge signed-chroma-pointers: 88.909090 -> 88.909090; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge signed-chroma-coefficients: 88.909090 -> 88.909090; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge signed-chroma-domain: 88.909090 -> 87.645454; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge byte-luminance: 88.909090 -> 88.909090; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 signed-chroma-pointers: 90.599075 -> 90.599075; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 signed-chroma-coefficients: 90.599075 -> 90.599075; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 signed-chroma-domain: 90.599075 -> 90.599075; restore
|
||||
TMCJPEGDEC_converterYUV422toRGB565 signed-chroma-pointers: 96.691180 -> 96.691180; restore
|
||||
TMCJPEGDEC_converterYUV422toRGB565 signed-chroma-coefficients: 96.691180 -> 96.691180; restore
|
||||
TMCJPEGDEC_converterYUV422toRGB565 signed-chroma-domain: 96.691180 -> 96.691180; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 signed-chroma-pointers: 94.609930 -> 94.609930; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 signed-chroma-coefficients: 94.609930 -> 94.609930; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 signed-chroma-domain: 94.609930 -> 94.609930; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 byte-luminance: 94.609930 -> 92.907800; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 signed-chroma-pointers: 97.967030 -> 97.362640; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 signed-chroma-coefficients: 97.967030 -> 97.802200; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 signed-chroma-domain: 97.967030 -> 97.340660; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 byte-luminance: 97.967030 -> 91.373630; restore
|
||||
```
|
||||
|
||||
### idct-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_IdctBlock_Lumi nested-odd-output-sum: 82.315180 -> 79.708170; restore
|
||||
TMCJPEGDEC_IdctBlock_Lumi explicit-ac-or-tree: 82.315180 -> 74.984436; restore
|
||||
TMCJPEGDEC_IdctBlock_Lumi ac-coefficients-direct-condition: 82.315180 -> 74.984436; restore
|
||||
TMCJPEGDEC_IdctBlock_Lumi nested-even-output-sum: 82.315180 -> 82.315180; restore
|
||||
TMCJPEGDEC_IdctBlock_Lumi direct-product-shifts: 82.315180 -> 82.315180; restore
|
||||
TMCJPEGDEC_IdctBlock_Col nested-odd-output-sum: 92.475770 -> 87.907486; restore
|
||||
TMCJPEGDEC_IdctBlock_Col explicit-ac-or-tree: 92.475770 -> 90.651985; restore
|
||||
TMCJPEGDEC_IdctBlock_Col ac-coefficients-direct-condition: 92.475770 -> 90.651985; restore
|
||||
TMCJPEGDEC_IdctBlock_Col nested-even-output-sum: 92.475770 -> 92.475770; restore
|
||||
TMCJPEGDEC_IdctBlock_Col direct-product-shifts: 92.475770 -> 92.475770; restore
|
||||
```
|
||||
|
||||
### packing-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_converterYUV411toRGBA8 explicit-channel-clamp-branches: 82.603300 -> 61.962810; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8 structured-nonnegative-clamp: 82.603300 -> 68.442150; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge explicit-channel-clamp-branches: 93.883930 -> 80.008930; restore
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge structured-nonnegative-clamp: 93.883930 -> 85.714290; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8 explicit-channel-clamp-branches: 87.722980 -> 71.222980; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8 structured-nonnegative-clamp: 87.722980 -> 75.533780; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge explicit-channel-clamp-branches: 90.088490 -> 76.097340; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge structured-nonnegative-clamp: 90.088490 -> 82.123890; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8 explicit-channel-clamp-branches: 89.405230 -> 73.372550; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8 structured-nonnegative-clamp: 89.405230 -> 76.797386; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge explicit-channel-clamp-branches: 87.400000 -> 77.841670; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge structured-nonnegative-clamp: 87.400000 -> 82.400000; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 explicit-channel-clamp-branches: 91.153850 -> 74.701920; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 structured-nonnegative-clamp: 91.153850 -> 82.211540; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge explicit-channel-clamp-branches: 92.000000 -> 77.730440; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge structured-nonnegative-clamp: 92.000000 -> 84.043480; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 explicit-channel-clamp-branches: 90.670105 -> 73.030930; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 structured-nonnegative-clamp: 90.670105 -> 81.082470; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge explicit-channel-clamp-branches: 88.909090 -> 75.463640; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge structured-nonnegative-clamp: 88.909090 -> 81.000000; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 normalize-packed-channels: 90.599075 -> 87.004610; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 group-red-green-packing: 90.599075 -> 88.755760; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 pack-before-output-address: 90.599075 -> 90.599075; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 explicit-channel-clamp-branches: 90.599075 -> 59.511520; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565 structured-nonnegative-clamp: 90.599075 -> 71.640560; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge normalize-packed-channels: 95.377360 -> 93.820755; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge group-red-green-packing: 95.377360 -> 93.613205; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge pack-before-output-address: 95.377360 -> 95.377360; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge explicit-channel-clamp-branches: 95.377360 -> 79.801890; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge structured-nonnegative-clamp: 95.377360 -> 86.179245; restore
|
||||
TMCJPEGDEC_converterYUV422toRGB565 explicit-channel-clamp-branches: 96.691180 -> 78.507355; restore
|
||||
TMCJPEGDEC_converterYUV422toRGB565 structured-nonnegative-clamp: 96.691180 -> 79.044120; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 normalize-packed-channels: 94.609930 -> 90.248230; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 group-red-green-packing: 94.609930 -> 91.560290; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 pack-before-output-address: 94.609930 -> 94.609930; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 explicit-channel-clamp-branches: 94.609930 -> 73.127660; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565 structured-nonnegative-clamp: 94.609930 -> 76.751770; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge normalize-packed-channels: 94.692986 -> 89.912280; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge group-red-green-packing: 94.692986 -> 91.798250; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge pack-before-output-address: 94.692986 -> 94.692986; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge explicit-channel-clamp-branches: 94.692986 -> 81.894740; restore
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge structured-nonnegative-clamp: 94.692986 -> 86.315790; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 normalize-packed-channels: 97.967030 -> 96.648350; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 group-red-green-packing: 97.967030 -> 98.681320; RETAIN
|
||||
TMCJPEGDEC_converterYUV444toRGB565 explicit-channel-clamp-branches: 98.681320 -> 85.120880; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 structured-nonnegative-clamp: 98.681320 -> 82.802200; restore
|
||||
```
|
||||
|
||||
### control-trials
|
||||
|
||||
```text
|
||||
structured-col-low-mode-first: {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577} -> {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577}; restore
|
||||
structured-col-high-mode-first: {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577} -> {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 50.55066}; restore
|
||||
shared-full-row-butterfly: {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577} -> {'TMCJPEGDEC_IdctBlock_Lumi': 83.05058, 'TMCJPEGDEC_IdctBlock_Col': 92.47577}; RETAIN
|
||||
```
|
||||
|
||||
### luma-reuse-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge consume-luminance-as-blue: 90.088490 -> 90.088490; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge consume-luminance-as-red: 90.088490 -> 89.955750; restore
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge consume-luminance-as-green: 90.088490 -> 90.088490; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge consume-luminance-as-blue: 87.400000 -> 87.400000; restore
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge consume-luminance-as-red: 87.400000 -> 87.458336; RETAIN
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 consume-luminance-as-blue: 91.153850 -> 91.153850; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 consume-luminance-as-red: 91.153850 -> 86.067310; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8 consume-luminance-as-green: 91.153850 -> 78.307690; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge consume-luminance-as-blue: 92.000000 -> 91.565216; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge consume-luminance-as-red: 92.000000 -> 87.617390; restore
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge consume-luminance-as-green: 92.000000 -> 79.547830; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 consume-luminance-as-blue: 90.670105 -> 90.670105; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 consume-luminance-as-red: 90.670105 -> 85.216490; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8 consume-luminance-as-green: 90.670105 -> 74.577320; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge consume-luminance-as-blue: 88.909090 -> 88.909090; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge consume-luminance-as-red: 88.909090 -> 85.645454; restore
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge consume-luminance-as-green: 88.909090 -> 78.772730; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge consume-luminance-as-blue: 95.377360 -> 91.396225; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge consume-luminance-as-red: 95.377360 -> 93.707550; restore
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge consume-luminance-as-green: 95.377360 -> 95.330185; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 consume-luminance-as-blue: 98.681320 -> 98.681320; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 consume-luminance-as-red: 98.681320 -> 98.714290; RETAIN
|
||||
```
|
||||
|
||||
### rgb444-trials
|
||||
|
||||
```text
|
||||
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-green-red-group: 98.714290 -> 89.923080; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-blue-green-group: 98.714290 -> 98.549450; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-red-blue-group: 98.714290 -> 90.945050; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-red-green-group: 98.714290 -> 98.714290; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-green-red-group: 98.714290 -> 98.131870; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-blue-green-group: 98.714290 -> 98.516490; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-red-blue-group: 98.714290 -> 91.406590; restore
|
||||
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-red-green-group: 98.714290 -> 98.681320; restore
|
||||
```
|
||||
29
tools/decomp-assist/jpeg-remainder-differential-results.txt
Normal file
29
tools/decomp-assist/jpeg-remainder-differential-results.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
TMCJPEGDEC_converterYUV411toRGBA8: 100 cases PASS; instruction coverage source 242/242, original 242/242
|
||||
TMCJPEGDEC_converterYUV411toRGBA8edge: 400 cases PASS; instruction coverage source 112/112, original 112/112
|
||||
TMCJPEGDEC_converterYUV422toRGBA8: 100 cases PASS; instruction coverage source 148/148, original 148/148
|
||||
TMCJPEGDEC_converterYUV422toRGBA8edge: 400 cases PASS; instruction coverage source 113/113, original 113/113
|
||||
TMCJPEGDEC_converterYUV420toRGBA8: 100 cases PASS; instruction coverage source 153/153, original 153/153
|
||||
TMCJPEGDEC_converterYUV420toRGBA8edge: 400 cases PASS; instruction coverage source 120/120, original 120/120
|
||||
TMCJPEGDEC_converterYUV211toRGBA8: 100 cases PASS; instruction coverage source 104/104, original 104/104
|
||||
TMCJPEGDEC_converterYUV211toRGBA8edge: 400 cases PASS; instruction coverage source 115/115, original 115/115
|
||||
TMCJPEGDEC_converterYUV444toRGBA8: 100 cases PASS; instruction coverage source 97/97, original 97/97
|
||||
TMCJPEGDEC_converterYUV444toRGBA8edge: 400 cases PASS; instruction coverage source 110/110, original 110/110
|
||||
TMCJPEGDEC_converterYUV400toRGBA8: 100 cases PASS; instruction coverage source 57/76, original 57/76
|
||||
TMCJPEGDEC_converterYUV400toRGBA8edge: 400 cases PASS; instruction coverage source 70/89, original 70/89
|
||||
TMCJPEGDEC_set_converterRGBA8: 1024 cases PASS; instruction coverage source 168/169, original 169/170
|
||||
TMCJPEGDEC_converterYUV411toRGB565: 100 cases PASS; instruction coverage source 217/217, original 217/217
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge: 400 cases PASS; instruction coverage source 106/106, original 106/106
|
||||
TMCJPEGDEC_converterYUV422toRGB565: 100 cases PASS; instruction coverage source 136/136, original 136/136
|
||||
TMCJPEGDEC_converterYUV422toRGB565edge: 400 cases PASS; instruction coverage source 107/107, original 107/107
|
||||
TMCJPEGDEC_converterYUV420toRGB565: 100 cases PASS; instruction coverage source 141/141, original 141/141
|
||||
TMCJPEGDEC_converterYUV420toRGB565edge: 400 cases PASS; instruction coverage source 114/114, original 114/114
|
||||
TMCJPEGDEC_converterYUV211toRGB565: 100 cases PASS; instruction coverage source 98/98, original 98/98
|
||||
TMCJPEGDEC_converterYUV211toRGB565edge: 400 cases PASS; instruction coverage source 109/109, original 109/109
|
||||
TMCJPEGDEC_converterYUV444toRGB565: 100 cases PASS; instruction coverage source 91/91, original 91/91
|
||||
TMCJPEGDEC_converterYUV444toRGB565edge: 400 cases PASS; instruction coverage source 104/104, original 104/104
|
||||
TMCJPEGDEC_converterYUV400toRGB565: 100 cases PASS; instruction coverage source 51/70, original 51/70
|
||||
TMCJPEGDEC_converterYUV400toRGB565edge: 400 cases PASS; instruction coverage source 64/83, original 64/83
|
||||
TMCJPEGDEC_set_converterRGB565: 1024 cases PASS; instruction coverage source 168/169, original 169/170
|
||||
TMCJPEGDEC_IdctBlock_Lumi: 704 cases PASS; instruction coverage source 257/257, original 257/257
|
||||
TMCJPEGDEC_IdctBlock_Col: 704 cases PASS; instruction coverage source 454/454, original 454/454
|
||||
TOTAL: 9456 differential cases PASS; GPR14-GPR31, stack pointer and LR preserved
|
||||
319
tools/decomp-assist/jpeg_differential_audit.py
Normal file
319
tools/decomp-assist/jpeg_differential_audit.py
Normal file
@@ -0,0 +1,319 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only, bounded PPC integer interpreter for differential JPEG checks.
|
||||
Loads source and original ELF .text; never copies original code into sources.
|
||||
Only memset is external. No FPU/system instructions are supported.
|
||||
"""
|
||||
import random
|
||||
import re
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
import capstone
|
||||
from elftools.elf.elffile import ELFFile
|
||||
U32 = 0xFFFFFFFF
|
||||
|
||||
def signed(x):
|
||||
x &= U32
|
||||
return x - 0x100000000 if x & 0x80000000 else x
|
||||
|
||||
def rotate(x, n):
|
||||
return (x << n | x >> (32 - n if n else 32)) & U32
|
||||
|
||||
def mask(b, e):
|
||||
return sum((1 << 31 - i for i in range(32) if b <= i <= e or (b > e and (i >= b or i <= e))))
|
||||
|
||||
def load_object(path):
|
||||
with open(path, 'rb') as f:
|
||||
e = ELFFile(f)
|
||||
section = e.get_section_by_name('.text')
|
||||
data = bytearray(section.data())
|
||||
syms = e.get_section_by_name('.symtab')
|
||||
calls = {}
|
||||
symbol_addresses = {}
|
||||
rel = e.get_section_by_name('.rela.text')
|
||||
if rel:
|
||||
for r in rel.iter_relocations():
|
||||
name = syms.get_symbol(r['r_info_sym']).name
|
||||
off = r['r_offset']
|
||||
typ = r['r_info_type']
|
||||
addr = 0x800000 + (zlib.crc32(name.encode()) & 0x7FFF) * 4 + r['r_addend']
|
||||
assert addr not in symbol_addresses or symbol_addresses[addr] == name
|
||||
symbol_addresses[addr] = name
|
||||
if typ == 10:
|
||||
calls[off] = name
|
||||
elif typ == 4:
|
||||
data[off:off + 2] = struct.pack('>H', addr & 65535)
|
||||
elif typ == 6:
|
||||
data[off:off + 2] = struct.pack('>H', addr + 0x8000 >> 16 & 65535)
|
||||
else:
|
||||
raise ValueError(('relocation', typ))
|
||||
dis = capstone.Cs(capstone.CS_ARCH_PPC, capstone.CS_MODE_32 | capstone.CS_MODE_BIG_ENDIAN)
|
||||
funcs = {}
|
||||
for sym in syms.iter_symbols():
|
||||
if sym['st_info']['type'] != 'STT_FUNC' or not sym['st_size']:
|
||||
continue
|
||||
start = sym['st_value']
|
||||
size = sym['st_size']
|
||||
inst = {}
|
||||
for i in dis.disasm(bytes(data[start:start + size]), start):
|
||||
ops = []
|
||||
for o in i.op_str.split(', '):
|
||||
if not o:
|
||||
continue
|
||||
if o.startswith('cr'):
|
||||
ops.append(('cr', int(o[2:])))
|
||||
elif o.startswith('r'):
|
||||
ops.append(int(o[1:]))
|
||||
elif '(' in o:
|
||||
off, reg = o.split('(')
|
||||
ops.append((int(off, 0), int(reg[1:-1])))
|
||||
else:
|
||||
ops.append(int(o, 0))
|
||||
inst[i.address] = (i.mnemonic, ops)
|
||||
funcs[sym.name] = (start, inst, calls)
|
||||
return funcs
|
||||
|
||||
def run(fn, initial, args):
|
||||
pc, ins, calls = fn
|
||||
mem = bytearray(initial)
|
||||
r = [i * 1122867 & U32 for i in range(32)]
|
||||
r[1] = 0x3F000
|
||||
r[3:3 + len(args)] = args
|
||||
saved_registers = r[14:].copy()
|
||||
cr = [0] * 8
|
||||
ctr = 0
|
||||
lr = 0
|
||||
steps = 0
|
||||
coverage = set()
|
||||
|
||||
def ld(a, n):
|
||||
assert 0 <= a <= len(mem) - n, hex(a)
|
||||
return int.from_bytes(mem[a:a + n], 'big')
|
||||
|
||||
def st(a, v, n):
|
||||
assert 0 <= a <= len(mem) - n, hex(a)
|
||||
mem[a:a + n] = (v & (1 << 8 * n) - 1).to_bytes(n, 'big')
|
||||
while True:
|
||||
steps += 1
|
||||
if steps > 100000:
|
||||
raise RuntimeError('step bound')
|
||||
coverage.add(pc)
|
||||
op, a = ins[pc]
|
||||
pc += 4
|
||||
dot = op.endswith('.')
|
||||
op = op.rstrip('.')
|
||||
val = None
|
||||
if op == 'blr':
|
||||
break
|
||||
elif op == 'bl':
|
||||
assert calls.get(pc - 4) == 'memset', calls.get(pc - 4)
|
||||
assert r[3] + r[5] <= len(mem)
|
||||
mem[r[3]:r[3] + r[5]] = bytes([r[4] & 255]) * r[5]
|
||||
# Model ABI-permitted call clobbers rather than preserving temporaries.
|
||||
for reg in [0] + list(range(4, 13)):
|
||||
r[reg] = (0xBAD00000 + reg) & U32
|
||||
for field in [0, 1, 5, 6, 7]:
|
||||
cr[field] = -1
|
||||
lr = pc
|
||||
elif op == 'b':
|
||||
pc = a[0]
|
||||
elif op == 'bdnz':
|
||||
ctr = ctr - 1 & U32
|
||||
if ctr:
|
||||
pc = a[0]
|
||||
elif op in ['beq', 'bne', 'ble', 'bge', 'blt', 'bgt']:
|
||||
c = cr[a[0][1]] if len(a) > 1 else cr[0]
|
||||
if {'beq': c == 0, 'bne': c != 0, 'ble': c <= 0, 'bge': c >= 0, 'blt': c < 0, 'bgt': c > 0}[op]:
|
||||
pc = a[-1]
|
||||
elif op in ['cmpwi', 'cmpw', 'cmplw']:
|
||||
c = a[0][1] if isinstance(a[0], tuple) else 0
|
||||
a = ins[pc - 4][1]
|
||||
if isinstance(a[0], tuple):
|
||||
a = a[1:]
|
||||
x = r[a[0]]
|
||||
y = a[1] if op == 'cmpwi' else r[a[1]]
|
||||
if op != 'cmplw':
|
||||
x = signed(x)
|
||||
y = signed(y)
|
||||
cr[c] = (x > y) - (x < y)
|
||||
elif op in ['lbz', 'lhz', 'lwz', 'lmw']:
|
||||
off, reg = a[1]
|
||||
addr = (r[reg] if reg else 0) + off & U32
|
||||
if op == 'lmw':
|
||||
for j in range(a[0], 32):
|
||||
r[j] = ld(addr + (j - a[0]) * 4, 4)
|
||||
else:
|
||||
r[a[0]] = ld(addr, {'lbz': 1, 'lhz': 2, 'lwz': 4}[op])
|
||||
elif op in ['stb', 'sth', 'stw', 'stwu', 'stmw']:
|
||||
off, reg = a[1]
|
||||
addr = (r[reg] if reg else 0) + off & U32
|
||||
if op == 'stmw':
|
||||
for j in range(a[0], 32):
|
||||
st(addr + (j - a[0]) * 4, r[j], 4)
|
||||
else:
|
||||
st(addr, r[a[0]], {'stb': 1, 'sth': 2, 'stw': 4, 'stwu': 4}[op])
|
||||
if op == 'stwu':
|
||||
r[reg] = addr
|
||||
elif op in ['stbx', 'sthx']:
|
||||
st((r[a[1]] if a[1] else 0) + r[a[2]] & U32, r[a[0]], 1 if op == 'stbx' else 2)
|
||||
elif op == 'mflr':
|
||||
r[a[0]] = lr
|
||||
elif op == 'mtlr':
|
||||
lr = r[a[0]]
|
||||
elif op == 'mtctr':
|
||||
ctr = r[a[0]]
|
||||
else:
|
||||
d = a[0]
|
||||
if op == 'li':
|
||||
val = a[1]
|
||||
elif op == 'lis':
|
||||
val = a[1] << 16
|
||||
elif op == 'mr':
|
||||
val = r[a[1]]
|
||||
elif op == 'add':
|
||||
val = r[a[1]] + r[a[2]]
|
||||
elif op == 'addi':
|
||||
val = (r[a[1]] if a[1] else 0) + a[2]
|
||||
elif op == 'addis':
|
||||
val = (r[a[1]] if a[1] else 0) + (a[2] << 16)
|
||||
elif op == 'subf':
|
||||
val = r[a[2]] - r[a[1]]
|
||||
elif op == 'subfic':
|
||||
val = a[2] - r[a[1]]
|
||||
elif op == 'mulli':
|
||||
val = r[a[1]] * a[2]
|
||||
elif op == 'mullw':
|
||||
val = r[a[1]] * r[a[2]]
|
||||
elif op == 'divw':
|
||||
x = signed(r[a[1]])
|
||||
y = signed(r[a[2]])
|
||||
val = abs(x) // abs(y) * (-1 if (x < 0) != (y < 0) else 1)
|
||||
elif op == 'or':
|
||||
val = r[a[1]] | r[a[2]]
|
||||
elif op == 'andc':
|
||||
val = r[a[1]] & ~r[a[2]]
|
||||
elif op == 'andi':
|
||||
val = r[a[1]] & a[2]
|
||||
elif op == 'neg':
|
||||
val = -r[a[1]]
|
||||
elif op == 'extsb':
|
||||
val = (r[a[1]] & 255) - (256 if r[a[1]] & 128 else 0)
|
||||
elif op == 'srawi':
|
||||
val = signed(r[a[1]]) >> a[2]
|
||||
elif op == 'srwi':
|
||||
val = r[a[1]] >> a[2]
|
||||
elif op == 'slwi':
|
||||
val = r[a[1]] << a[2]
|
||||
elif op == 'clrlwi':
|
||||
val = r[a[1]] & (1 << 32 - a[2]) - 1
|
||||
elif op == 'rotlwi':
|
||||
val = rotate(r[a[1]], a[2])
|
||||
elif op == 'rlwinm':
|
||||
val = rotate(r[a[1]], a[2]) & mask(a[3], a[4])
|
||||
else:
|
||||
raise ValueError((hex(pc - 4), op, a))
|
||||
r[d] = val & U32
|
||||
if dot:
|
||||
cr[0] = (signed(val) > 0) - (signed(val) < 0)
|
||||
assert r[1] == 0x3F000, 'Stack pointer not restored'
|
||||
assert lr == 0, 'Link register not restored'
|
||||
assert r[14:] == saved_registers, 'Nonvolatile registers not restored'
|
||||
return (mem, r[3], coverage)
|
||||
|
||||
def put(m, a, v, n=4):
|
||||
m[a:a + n] = (v & (1 << 8 * n) - 1).to_bytes(n, 'big')
|
||||
|
||||
def compare(src, orig, name, m, args, case, returns=False):
|
||||
a, ra, ca = run(src[name], m, args)
|
||||
b, rb, cb = run(orig[name], m, args)
|
||||
# The stack can differ because each implementation owns its frame.
|
||||
if a[:0x3E000] != b[:0x3E000]:
|
||||
diff = [hex(i) for i in range(0x3E000) if a[i] != b[i]][:12]
|
||||
raise AssertionError((name, case, 'memory mismatch', diff))
|
||||
if returns and ra != rb:
|
||||
raise AssertionError((name, case, 'return', ra, rb))
|
||||
return (ca, cb)
|
||||
|
||||
def main():
|
||||
total_cases = 0
|
||||
rng = random.Random(449529)
|
||||
root = 'build/43U/{}/libs/RVLMiddleware/TMC_JPEG/src/{}'
|
||||
for unit in ['texturecvtr/Texture_MCUtoRGBA8', 'texturecvtr/Texture_MCUtoRGB565', 'buffer/idct_block_var']:
|
||||
src = load_object(root.format('src', unit) + '.o')
|
||||
orig = load_object(root.format('obj', unit) + '.o')
|
||||
assert src.keys() == orig.keys(), (unit, 'Function sets differ')
|
||||
assert len(src) == (2 if unit.startswith('buffer/') else 13)
|
||||
for name in src:
|
||||
n = 0
|
||||
sa = set()
|
||||
sb = set()
|
||||
if 'IdctBlock' in name:
|
||||
for rows in range(1, 9):
|
||||
for cols in [1, 2, 3, 8]:
|
||||
for pattern in range(22):
|
||||
m = bytearray([0xA5]) * 0x40000
|
||||
block = [0] * 64
|
||||
for y in range(rows):
|
||||
for x in range(cols):
|
||||
if pattern < 6:
|
||||
block[y * 8 + x] = [0, 1, -1, 0x3FFFF, 0x40000, -0x40000][pattern] if x == 0 and y == 0 else 0
|
||||
elif pattern < 14:
|
||||
block[y * 8 + x] = rng.randrange(-10000, 10001) if rng.randrange(4) == 0 else 0
|
||||
else:
|
||||
block[y * 8 + x] = rng.randrange(-150000, 150001)
|
||||
for i, v in enumerate(block):
|
||||
put(m, 0x1000 + i * 4, v)
|
||||
pitch = [8, 16, 32][pattern % 3]
|
||||
args = [0x1000, 0x2000, pitch, rows << 4 | cols]
|
||||
ca, cb = compare(src, orig, name, m, args, (rows, cols, pattern))
|
||||
sa |= ca
|
||||
sb |= cb
|
||||
n += 1
|
||||
elif 'set_converter' in name:
|
||||
for component in range(256):
|
||||
for mode in [1, 2, 4, 8]:
|
||||
m = bytearray([0xA5]) * 0x40000
|
||||
work = 0x1000
|
||||
state = 0x4000
|
||||
put(m, work + 0x17FC, component, 1)
|
||||
put(m, work + 0x19DC, mode, 1)
|
||||
put(m, work + 0x19E4, state)
|
||||
put(m, state + 0x24, rng.randrange(65536), 2)
|
||||
put(m, state + 0x26, rng.randrange(65536), 2)
|
||||
ca, cb = compare(src, orig, name, m, [work], (component, mode), True)
|
||||
sa |= ca
|
||||
sb |= cb
|
||||
n += 1
|
||||
else:
|
||||
sampling = re.search('YUV(\\d+)to', name)[1]
|
||||
w, h = {'411': (32, 8), '422': (16, 8), '420': (16, 16), '211': (8, 16), '444': (8, 8), '400': (8, 8)}[sampling]
|
||||
for scale in [1, 2, 4, 8]:
|
||||
for pattern in range(25):
|
||||
for border in range(4 if name.endswith('edge') else 1):
|
||||
m = bytearray([0xA5]) * 0x40000
|
||||
work = 0x1000
|
||||
state = 0x4000
|
||||
tex = 0x8000
|
||||
x = 32 * (pattern % 2)
|
||||
y = 16 * (pattern % 3)
|
||||
ww = w // scale
|
||||
hh = h // scale
|
||||
put(m, work + 0x19E4, state)
|
||||
put(m, state + 0x20, scale, 1)
|
||||
put(m, state + 0x2C, 96)
|
||||
put(m, state + 0x48, tex)
|
||||
put(m, state + 0x18, x if border & 1 else x + 1)
|
||||
put(m, state + 0x1C, y if border & 2 else y + 1)
|
||||
put(m, state + 0x16, pattern % (ww + 1), 1)
|
||||
put(m, state + 0x17, pattern % (hh + 1), 1)
|
||||
for i in range(0x184):
|
||||
m[work + 0x1858 + i] = [0, 127, 128, 255][pattern % 4] if pattern < 4 else rng.randrange(256)
|
||||
ca, cb = compare(src, orig, name, m, [work, x, y], (scale, pattern, border))
|
||||
sa |= ca
|
||||
sb |= cb
|
||||
n += 1
|
||||
total_cases += n
|
||||
print(f'{name}: {n} cases PASS; instruction coverage source {len(sa)}/{len(src[name][1])}, original {len(sb)}/{len(orig[name][1])}', flush=True)
|
||||
print(f'TOTAL: {total_cases} differential cases PASS; GPR14-GPR31, stack pointer and LR preserved')
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
368
tools/decomp-assist/jpeg_exif_differential_audit.py
Normal file
368
tools/decomp-assist/jpeg_exif_differential_audit.py
Normal file
@@ -0,0 +1,368 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only, bounded PPC integer interpreter for differential EXIF checks.
|
||||
Loads source and original ELF .text; never copies original code into sources.
|
||||
Only internal EXIF calls are supported. No FPU/system instructions are supported.
|
||||
"""
|
||||
import random
|
||||
import re
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
import capstone
|
||||
from elftools.elf.elffile import ELFFile
|
||||
U32 = 0xFFFFFFFF
|
||||
|
||||
def signed(x):
|
||||
x &= U32
|
||||
return x - 0x100000000 if x & 0x80000000 else x
|
||||
|
||||
def rotate(x, n):
|
||||
return (x << n | x >> (32 - n if n else 32)) & U32
|
||||
|
||||
def mask(b, e):
|
||||
return sum((1 << 31 - i for i in range(32) if b <= i <= e or (b > e and (i >= b or i <= e))))
|
||||
|
||||
def load_object(path):
|
||||
with open(path, 'rb') as f:
|
||||
e = ELFFile(f)
|
||||
section = e.get_section_by_name('.text')
|
||||
data = bytearray(section.data())
|
||||
syms = e.get_section_by_name('.symtab')
|
||||
calls = {}
|
||||
symbol_addresses = {}
|
||||
rel = e.get_section_by_name('.rela.text')
|
||||
if rel:
|
||||
for r in rel.iter_relocations():
|
||||
name = syms.get_symbol(r['r_info_sym']).name
|
||||
off = r['r_offset']
|
||||
typ = r['r_info_type']
|
||||
addr = 0x800000 + (zlib.crc32(name.encode()) & 0x7FFF) * 4 + r['r_addend']
|
||||
assert addr not in symbol_addresses or symbol_addresses[addr] == name
|
||||
symbol_addresses[addr] = name
|
||||
if typ == 10:
|
||||
calls[off] = name
|
||||
elif typ == 4:
|
||||
data[off:off + 2] = struct.pack('>H', addr & 65535)
|
||||
elif typ == 6:
|
||||
data[off:off + 2] = struct.pack('>H', addr + 0x8000 >> 16 & 65535)
|
||||
else:
|
||||
raise ValueError(('relocation', typ))
|
||||
dis = capstone.Cs(capstone.CS_ARCH_PPC, capstone.CS_MODE_32 | capstone.CS_MODE_BIG_ENDIAN)
|
||||
funcs = {}
|
||||
for sym in syms.iter_symbols():
|
||||
if sym['st_info']['type'] != 'STT_FUNC' or not sym['st_size']:
|
||||
continue
|
||||
start = sym['st_value']
|
||||
size = sym['st_size']
|
||||
inst = {}
|
||||
for i in dis.disasm(bytes(data[start:start + size]), start):
|
||||
ops = []
|
||||
for o in i.op_str.split(', '):
|
||||
if not o:
|
||||
continue
|
||||
if o.startswith('cr'):
|
||||
ops.append(('cr', int(o[2:])))
|
||||
elif o.startswith('r'):
|
||||
ops.append(int(o[1:]))
|
||||
elif '(' in o:
|
||||
off, reg = o.split('(')
|
||||
ops.append((int(off, 0), int(reg[1:-1])))
|
||||
else:
|
||||
ops.append(int(o, 0))
|
||||
inst[i.address] = (i.mnemonic, ops)
|
||||
funcs[sym.name] = (start, inst, calls)
|
||||
return funcs
|
||||
|
||||
def run(functions, name, initial, args):
|
||||
pc = functions[name][0]
|
||||
ins = {address: instruction for _, body, _ in functions.values() for address, instruction in body.items()}
|
||||
calls = functions[name][2]
|
||||
mem = bytearray(initial)
|
||||
r = [i * 1122867 & U32 for i in range(32)]
|
||||
r[1] = 0x3F000
|
||||
r[3:3 + len(args)] = args
|
||||
saved_registers = r[14:].copy()
|
||||
cr = [0] * 8
|
||||
ctr = 0
|
||||
lr = 0
|
||||
steps = 0
|
||||
coverage = set()
|
||||
|
||||
def ld(a, n):
|
||||
assert 0 <= a <= len(mem) - n, hex(a)
|
||||
return int.from_bytes(mem[a:a + n], 'big')
|
||||
|
||||
def st(a, v, n):
|
||||
assert 0 <= a <= len(mem) - n, hex(a)
|
||||
mem[a:a + n] = (v & (1 << 8 * n) - 1).to_bytes(n, 'big')
|
||||
while True:
|
||||
steps += 1
|
||||
if steps > 100000:
|
||||
raise RuntimeError('step bound')
|
||||
coverage.add(pc)
|
||||
op, a = ins[pc]
|
||||
pc += 4
|
||||
dot = op.endswith('.')
|
||||
op = op.rstrip('.')
|
||||
val = None
|
||||
if op == 'blr':
|
||||
if lr == 0:
|
||||
break
|
||||
pc = lr
|
||||
elif op == 'bl':
|
||||
callee = calls.get(pc - 4)
|
||||
assert callee in functions, ('Unsupported external call', callee)
|
||||
lr = pc
|
||||
pc = functions[callee][0]
|
||||
elif op == 'b':
|
||||
pc = a[0]
|
||||
elif op == 'bdnz':
|
||||
ctr = ctr - 1 & U32
|
||||
if ctr:
|
||||
pc = a[0]
|
||||
elif op in ['beqlr', 'bnelr', 'blelr', 'bgelr', 'bltlr', 'bgtlr']:
|
||||
c = cr[a[0][1]] if a else cr[0]
|
||||
condition = {'beqlr': c == 0, 'bnelr': c != 0, 'blelr': c <= 0, 'bgelr': c >= 0, 'bltlr': c < 0, 'bgtlr': c > 0}[op]
|
||||
if condition:
|
||||
if lr == 0:
|
||||
break
|
||||
pc = lr
|
||||
elif op in ['beq', 'bne', 'ble', 'bge', 'blt', 'bgt']:
|
||||
c = cr[a[0][1]] if len(a) > 1 else cr[0]
|
||||
if {'beq': c == 0, 'bne': c != 0, 'ble': c <= 0, 'bge': c >= 0, 'blt': c < 0, 'bgt': c > 0}[op]:
|
||||
pc = a[-1]
|
||||
elif op in ['cmpwi', 'cmpw', 'cmplw', 'cmplwi']:
|
||||
c = a[0][1] if isinstance(a[0], tuple) else 0
|
||||
a = ins[pc - 4][1]
|
||||
if isinstance(a[0], tuple):
|
||||
a = a[1:]
|
||||
x = r[a[0]]
|
||||
y = a[1] if op in ['cmpwi', 'cmplwi'] else r[a[1]]
|
||||
if op not in ['cmplw', 'cmplwi']:
|
||||
x = signed(x)
|
||||
y = signed(y)
|
||||
cr[c] = (x > y) - (x < y)
|
||||
elif op in ['lbz', 'lhz', 'lwz', 'lmw']:
|
||||
off, reg = a[1]
|
||||
addr = (r[reg] if reg else 0) + off & U32
|
||||
if op == 'lmw':
|
||||
for j in range(a[0], 32):
|
||||
r[j] = ld(addr + (j - a[0]) * 4, 4)
|
||||
else:
|
||||
r[a[0]] = ld(addr, {'lbz': 1, 'lhz': 2, 'lwz': 4}[op])
|
||||
elif op in ['stb', 'sth', 'stw', 'stwu', 'stmw']:
|
||||
off, reg = a[1]
|
||||
addr = (r[reg] if reg else 0) + off & U32
|
||||
if op == 'stmw':
|
||||
for j in range(a[0], 32):
|
||||
st(addr + (j - a[0]) * 4, r[j], 4)
|
||||
else:
|
||||
st(addr, r[a[0]], {'stb': 1, 'sth': 2, 'stw': 4, 'stwu': 4}[op])
|
||||
if op == 'stwu':
|
||||
r[reg] = addr
|
||||
elif op in ['stbx', 'sthx']:
|
||||
st((r[a[1]] if a[1] else 0) + r[a[2]] & U32, r[a[0]], 1 if op == 'stbx' else 2)
|
||||
elif op == 'mflr':
|
||||
r[a[0]] = lr
|
||||
elif op == 'mtlr':
|
||||
lr = r[a[0]]
|
||||
elif op == 'mtctr':
|
||||
ctr = r[a[0]]
|
||||
else:
|
||||
d = a[0]
|
||||
if op == 'li':
|
||||
val = a[1]
|
||||
elif op == 'lis':
|
||||
val = a[1] << 16
|
||||
elif op == 'mr':
|
||||
val = r[a[1]]
|
||||
elif op == 'add':
|
||||
val = r[a[1]] + r[a[2]]
|
||||
elif op == 'addi':
|
||||
val = (r[a[1]] if a[1] else 0) + a[2]
|
||||
elif op == 'addis':
|
||||
val = (r[a[1]] if a[1] else 0) + (a[2] << 16)
|
||||
elif op == 'subf':
|
||||
val = r[a[2]] - r[a[1]]
|
||||
elif op == 'subfic':
|
||||
val = a[2] - r[a[1]]
|
||||
elif op == 'mulli':
|
||||
val = r[a[1]] * a[2]
|
||||
elif op == 'mullw':
|
||||
val = r[a[1]] * r[a[2]]
|
||||
elif op == 'divw':
|
||||
x = signed(r[a[1]])
|
||||
y = signed(r[a[2]])
|
||||
val = abs(x) // abs(y) * (-1 if (x < 0) != (y < 0) else 1)
|
||||
elif op == 'or':
|
||||
val = r[a[1]] | r[a[2]]
|
||||
elif op == 'andc':
|
||||
val = r[a[1]] & ~r[a[2]]
|
||||
elif op == 'andi':
|
||||
val = r[a[1]] & a[2]
|
||||
elif op == 'neg':
|
||||
val = -r[a[1]]
|
||||
elif op == 'extsb':
|
||||
val = (r[a[1]] & 255) - (256 if r[a[1]] & 128 else 0)
|
||||
elif op == 'srawi':
|
||||
val = signed(r[a[1]]) >> a[2]
|
||||
elif op == 'srwi':
|
||||
val = r[a[1]] >> a[2]
|
||||
elif op == 'slwi':
|
||||
val = r[a[1]] << a[2]
|
||||
elif op == 'clrlwi':
|
||||
val = r[a[1]] & (1 << 32 - a[2]) - 1
|
||||
elif op == 'rotlwi':
|
||||
val = rotate(r[a[1]], a[2])
|
||||
elif op == 'rlwimi':
|
||||
bits = mask(a[3], a[4])
|
||||
val = (r[d] & ~bits) | (rotate(r[a[1]], a[2]) & bits)
|
||||
elif op == 'rlwinm':
|
||||
val = rotate(r[a[1]], a[2]) & mask(a[3], a[4])
|
||||
else:
|
||||
raise ValueError((hex(pc - 4), op, a))
|
||||
r[d] = val & U32
|
||||
if dot:
|
||||
cr[0] = (signed(val) > 0) - (signed(val) < 0)
|
||||
assert r[1] == 0x3F000, 'Stack pointer not restored'
|
||||
assert lr == 0, 'Link register not restored'
|
||||
assert r[14:] == saved_registers, 'Nonvolatile registers not restored'
|
||||
return (mem, r[3], coverage)
|
||||
|
||||
def put(m, a, v, n=4):
|
||||
m[a:a + n] = (v & (1 << 8 * n) - 1).to_bytes(n, 'big')
|
||||
|
||||
def compare(src, orig, name, m, args, case, returns=False):
|
||||
a, ra, ca = run(src, name, m, args)
|
||||
b, rb, cb = run(orig, name, m, args)
|
||||
# The stack can differ because each implementation owns its frame.
|
||||
if a[:0x3E000] != b[:0x3E000]:
|
||||
diff = [hex(i) for i in range(0x3E000) if a[i] != b[i]][:12]
|
||||
raise AssertionError((name, case, 'memory mismatch', diff))
|
||||
if returns and ra != rb:
|
||||
raise AssertionError((name, case, 'return', ra, rb))
|
||||
return (ca, cb)
|
||||
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
from collections import defaultdict
|
||||
path = 'build/43U/{}/libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse.o'
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--source-object', default=path.format('src'))
|
||||
parser.add_argument('--target-object', default=path.format('obj'))
|
||||
parser.add_argument('--overlap-only', action='store_true')
|
||||
args = parser.parse_args()
|
||||
src = load_object(args.source_object)
|
||||
orig = load_object(args.target_object)
|
||||
assert src.keys() == orig.keys()
|
||||
assert len(src) == 6
|
||||
names = ['TMCJPEGDEC_IFD0_tag_parse', 'TMCJPEGDEC_IFD1_tag_parse', 'TMCJPEGDEC_exif_parse']
|
||||
coverage = {name: [set(), set()] for name in names}
|
||||
counts = defaultdict(int)
|
||||
rng = random.Random(449529)
|
||||
info, entry, data = 0x1000, 0x2000, 0x3000
|
||||
memory = bytearray([0xA5]) * 0x40000
|
||||
memory[data:data + 0x2000] = bytes(rng.randrange(256) for _ in range(0x2000))
|
||||
put(memory, info + 0x674, data)
|
||||
put(memory, info + 0x678, data + 0x1000)
|
||||
|
||||
def exif_put(m, pos, value, size, order):
|
||||
m[pos:pos + size] = (value & ((1 << (8 * size)) - 1)).to_bytes(size, 'little' if order == 0x4949 else 'big')
|
||||
|
||||
def check(name, m, args, case, returns=False):
|
||||
ca, cb = compare(src, orig, name, m, args, case, returns)
|
||||
coverage[name][0].update(ca)
|
||||
coverage[name][1].update(cb)
|
||||
counts[name] += 1
|
||||
|
||||
for order in [0x4949, 0x4D4D]:
|
||||
for tag, offset in [(0x9000, 0x63C), (0x9101, 0x640), (0xA000, 0x644)]:
|
||||
for delta in range(-3, 4):
|
||||
m = bytearray(memory)
|
||||
destination = info + offset
|
||||
aliased_entry = destination + delta - 8
|
||||
exif_put(m, aliased_entry, tag, 2, order)
|
||||
m[aliased_entry + 8:aliased_entry + 12] = bytes([1, 2, 3, 4])
|
||||
check(names[0], m, [info, order, aliased_entry], ('overlapping-version-bytes', order, tag, delta))
|
||||
|
||||
if args.overlap_only:
|
||||
print('TOTAL', sum(counts.values()), 'overlapping version-byte calls PASS')
|
||||
return
|
||||
|
||||
for name in names[:2]:
|
||||
selector_start = counts[name]
|
||||
for order in [0x4949, 0x4D4D]:
|
||||
exif_put(memory, entry + 2, 4, 2, order)
|
||||
exif_put(memory, entry + 4, 1, 4, order)
|
||||
exif_put(memory, entry + 8, 0x100, 4, order)
|
||||
for tag in range(0x10000):
|
||||
exif_put(memory, entry, tag, 2, order)
|
||||
check(name, memory, [info, order, entry], ('all-tags', order, tag))
|
||||
print(name, counts[name] - selector_start, 'selector cases PASS', flush=True)
|
||||
for order in [0x4949, 0x4D4D]:
|
||||
for tag in [0x103, 0x112, 0x11A, 0x11B, 0x128, 0x12D, 0x132, 0x201, 0x202, 0x213, 0x8769, 0x9000, 0x9101, 0xA000, 0xA001, 0xA002, 0xA003]:
|
||||
exif_put(memory, entry, tag, 2, order)
|
||||
for field_type in [0, 3, 4, 0xFFFF]:
|
||||
exif_put(memory, entry + 2, field_type, 2, order)
|
||||
for offset in [0, 1, 0xFF0, 0xFEC, 0xFF8, 0xFFC, 0xFFE, 0xFFF, 0x1000, 0x1001, 0xFFFFFFFF, 0xFFFFD000]:
|
||||
exif_put(memory, entry + 8, offset, 4, order)
|
||||
check(name, memory, [info, order, entry], ('bounds', order, tag, field_type, offset))
|
||||
|
||||
name = names[2]
|
||||
for order in [0x4949, 0x4D4D, 0, 0x1234]:
|
||||
for size in [0, 1, 7, 8, 9, 10, 13, 14, 25, 26, 40, 64, 128, 0x1000]:
|
||||
for ifd_offset in [0, 2, 8, 10, 0x1000, 0xFFFFFFFF]:
|
||||
for count in [0, 1, 2, 0xFFFF]:
|
||||
m = bytearray(memory)
|
||||
m[data:data + 0x1000] = bytes(0x1000)
|
||||
exif_put(m, data, order, 2, order)
|
||||
exif_put(m, data + 2, 42, 2, order)
|
||||
exif_put(m, data + 4, ifd_offset, 4, order)
|
||||
if 8 <= ifd_offset < 0x1000:
|
||||
exif_put(m, data + ifd_offset, count, 2, order)
|
||||
check(name, m, [data, size, info], ('header-bounds', order, size, ifd_offset, count), True)
|
||||
|
||||
for order in [0x4949, 0x4D4D]:
|
||||
for magic in [0, 41, 43, 0xFFFF]:
|
||||
m = bytearray(memory)
|
||||
exif_put(m, data, order, 2, order)
|
||||
exif_put(m, data + 2, magic, 2, order)
|
||||
check(name, m, [data, 128, info], ('invalid-TIFF-magic', order, magic), True)
|
||||
|
||||
for order in [0x4949, 0x4D4D]:
|
||||
for count0 in [0, 1, 2, 3]:
|
||||
for count1 in [0, 1, 2, 3]:
|
||||
for size in [40, 64, 65, 66, 70, 79, 80, 100, 128, 129, 130, 140, 144, 160, 256]:
|
||||
m = bytearray(memory)
|
||||
m[data:data + 0x1000] = bytes(0x1000)
|
||||
exif_put(m, data, order, 2, order)
|
||||
exif_put(m, data + 2, 42, 2, order)
|
||||
exif_put(m, data + 4, 8, 4, order)
|
||||
exif_put(m, data + 8, count0, 2, order)
|
||||
for index, tag in enumerate([0x112, 0xA002, 0x8769][:count0]):
|
||||
pos = data + 10 + index * 12
|
||||
exif_put(m, pos, tag, 2, order)
|
||||
exif_put(m, pos + 2, 4, 2, order)
|
||||
exif_put(m, pos + 8, 128 if tag == 0x8769 else 3, 4, order)
|
||||
exif_put(m, data + 10 + count0 * 12, 64, 4, order)
|
||||
exif_put(m, data + 64, count1, 2, order)
|
||||
for index, tag in enumerate([0x103, 0x201, 0x202][:count1]):
|
||||
pos = data + 66 + index * 12
|
||||
exif_put(m, pos, tag, 2, order)
|
||||
exif_put(m, pos + 2, 4, 2, order)
|
||||
exif_put(m, pos + 8, 6, 4, order)
|
||||
exif_put(m, data + 128, 1, 2, order)
|
||||
exif_put(m, data + 130, 0xA003, 2, order)
|
||||
exif_put(m, data + 132, 4, 2, order)
|
||||
exif_put(m, data + 138, 640, 4, order)
|
||||
check(name, m, [data, size, info], ('directory-chain', order, count0, count1, size), True)
|
||||
|
||||
for name in names:
|
||||
source_body = set(src[name][1])
|
||||
original_body = set(orig[name][1])
|
||||
print(name, counts[name], 'cases PASS; own-body instruction coverage', len(coverage[name][0] & source_body), '/', len(source_body), 'source;', len(coverage[name][1] & original_body), '/', len(original_body), 'original', flush=True)
|
||||
print('TOTAL', sum(counts.values()), 'paired EXIF calls PASS')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
51
tools/decomp-assist/run-fixed-stack.attempts.md
Normal file
51
tools/decomp-assist/run-fixed-stack.attempts.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Run fixed-stack relocation correction
|
||||
|
||||
This is a narrow follow-up to #973, not another Run implementation or a new
|
||||
match. The existing assembly, cache loop, register clearing, labels and handoff
|
||||
remain intact. No linking flag changes.
|
||||
|
||||
## Evidence
|
||||
|
||||
The hash-verified original DOL and linked ELF contain Run at 0x8137B3EC,
|
||||
size 0xAC (43 instructions). Its instructions at 0x8137B468/0x8137B46C establish
|
||||
SP as 0x81600000. This architectural stack value should not depend on placement
|
||||
of an unrelated formatted-output routine.
|
||||
|
||||
Automatic extraction had attached two relocations to __pformatter + 0x280:
|
||||
R_PPC_ADDR16_HI at Run+0x7E and R_PPC_ADDR16_LO at Run+0x82. The linked formatter
|
||||
address happens to make this expression equal 0x81600000 in this target, but
|
||||
that is a false semantic dependency in the reconstruction.
|
||||
|
||||
DTK block_relocations uses instruction addresses, not ELF halfword offsets.
|
||||
The two exclusions are therefore .text:0x8137B468 and .text:0x8137B46C.
|
||||
The source removes the unrelated extern and uses the fixed high/low immediate.
|
||||
No other source instructions or original bytes are replaced.
|
||||
|
||||
## Independent validation
|
||||
|
||||
- Full 43U all_source, progress, report and DOL check pass.
|
||||
- Original app and rebuilt DOL SHA1 both remain
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
- Run remains 100%, 43/43 instructions, ctxdiff zero. No new match attribution.
|
||||
- Whole report is unchanged: no code, data, function, linking or fuzzy delta.
|
||||
- Pool: all 91 strings identical.
|
||||
- All 1027 native source objects compared: only BS2Mach .text changes; size
|
||||
16960 is unchanged. Exactly the two false text relocations are removed.
|
||||
All other allocated objects and data sections are unchanged.
|
||||
- All 1027 active extracted objects compared, plus the same obsolete cached
|
||||
tiManager.o in both trees. Only BS2Mach .text changes: size 16980 unchanged;
|
||||
only Run's high immediate placeholder bytes at +0x7E/+0x7F become 0x81,0x60.
|
||||
Exactly the two formatter relocations disappear, with no added relocations.
|
||||
Defined target symbols and non-text sections stay unchanged.
|
||||
- Supplemental integer-PPC contract model checks the compiled source for 1,
|
||||
4 and 131072 cache lines, preserved LR entry, SP 0x81600000, cleared GPRs and
|
||||
alternating dcbz/dcbf events. The zero-count prefix retains the original CTR
|
||||
wrap to 0xFFFFFFFF; the full 2^32-iteration path is not executed. This is an
|
||||
abstract contract test, not actual cache/MMIO or console execution.
|
||||
- Workflow/literal/jump-table/pool tests: 8/36/27/8 passed.
|
||||
- Diff check passes.
|
||||
|
||||
Assembly was already introduced by #973. The original isolated full-Run
|
||||
experiment is deliberately not included here. This correction adds no new
|
||||
assembly instructions, forced register uses, retail .s objects or padding.
|
||||
Please review the metadata/source constant attribution explicitly.
|
||||
Reference in New Issue
Block a user