xenia icon indicating copy to clipboard operation
xenia copied to clipboard

FinalizationPass::Run only sets Label::name properly for labels 0-9999

Open emoose opened this issue 3 years ago • 1 comments

Moving this issue over from https://github.com/xenia-project/game-compatibility/issues/245#issuecomment-843539147, FinalizationPass::Run only allocates a buffer for Label::name with 4 chars for the ID, limiting it to storing 0-9999: https://github.com/xenia-project/xenia/blob/800db1aa49814e12044809b52ed69d0dd941a740/src/xenia/cpu/compiler/passes/finalization_pass.cc#L47-L49

Labels that have IDs larger than 9999 will have it truncated in the name string, usually causing Xbyak to crash out, I guess due to labels sharing the same name.

This can be bypassed by enabling disassemble_functions=true, as that seems to setup Label::name using a different format for the name before FinalizationPass::Run is executed. Obviously not a great fix though, but still pretty neat that it works.

There's a few games in the compatibility tracker that mention only working with disassemble_functions=true set, probably mostly all related to this issue. Extending the buffer that gets allocated seems to let some of them work (simplest way is probably allocating 8 bytes and storing the ID as hex?), at least Avatar: TLA worked without needing disassemble_functions set.

Not sure if this is actually the root cause though, could something else be going wrong for it to be creating Labels with IDs greater than 9999?

emoose avatar May 24 '21 01:05 emoose

I've created a game-compatibility label for this: requires_disassemble_functions_true

Margen67 avatar Feb 03 '22 08:02 Margen67

What exactly is limiting this string to a fixed size at all?

Triang3l avatar Aug 11 '23 13:08 Triang3l