Closed dlbuhtig4096 closed 9 months ago
Hey! Thanks for the bug report!
Sadly I can't reproduce the issue myself. I cloned the repo and followed the README instructions and the build produces an OK instead of a linker error.
On a further inspection of the generated assembly.
/* 93D9C 8009319C 8001ACF4 */ .word .L8001ACF4
/* 93DA0 800931A0 8001B1AC */ .word .L8001B1AC
/* 93DA4 800931A4 8001AD78 */ .word .L8001AD78
glabel
:
/* 1BDA4 8001B1A4 10000006 */ b .L8001B1C0
/* 1BDA8 8001B1A8 26390003 */ addiu $t9, $s1, 0x3
glabel .L8001B1AC
/* 1BDAC 8001B1AC 3C048009 */ lui $a0, %hi(D_800930E4)
/* 1BDB0 8001B1B0 8FA502F8 */ lw $a1, 0x2F8($sp)
/* 1BDB4 8001B1B4 0C0003EF */ jal errstop
/* 1B970 8001AD70 10000112 */ b .L8001B1BC
/* 1B974 8001AD74 2413000F */ addiu $s3, $zero, 0xF
glabel .L8001AD78
/* 1B978 8001AD78 26380003 */ addiu $t8, $s1, 0x3
/* 1B97C 8001AD7C 03128824 */ and $s1, $t8, $s2
/* 1B980 8001AD80 8E220000 */ lw $v0, 0x0($s1)
.L8001A44C
from the obj2Shell
function (the one you showed) does indeed not emit a glabel
, but that's because the label is not unused anywhere outside the function itself (it isn't referenced by a jumptable).Seems like we are running the same spimdisasm version.
Which splat version did you use to test this? Try to check if yours is somehow outdated. Seems like the splat submodule I used is 0.21.6. You can check the splat version by simply running it, it will print something like this:
splat 0.21.6 (powered by spimdisasm 1.20.0)
My Python version is 3.10.12 and I'm running on a native Linux distro. Are you running this on native Windows 11 or are you using WSL? Both spimdisasm and splat should behave the regarding the Python version or OS it runs on, otherwise it would be pretty worrying.
lmk if you have any more info to try to reproduce this issue
I am talking to them on discord and they are using Msys to run this. I use 3.10.6 and they use Python 3.11.5 and I tried 3.11.7 and that didnt reproduce it (I couldnt find an exact apt-get of 3.11.5 from WSL aptget). I also made sure to make my requirements.txt versions match their module versions and that didnt reproduce it issue. It's gotta be either some weird 3.11.5 bug (cascading into a spimdisasm issue) or a horrible environment issue as a result of using msys.
How does Msys handle Python? Is it like its own shell or is it running on a plain Windows cmd/powershell?
You could try running splat on a cmd/powershell directly instead of passing through Msys to see if that's somehow related
How does Msys handle Python? Is it like its own shell or is it running on a plain Windows cmd/powershell?
You could try running splat on a cmd/powershell directly instead of passing through Msys to see if that's somehow related
No I have run the script in cmd and anaconda3 prompt, both produced the exact same result. And I have tried standalone python 3.11.7 as well, the problem presists.
I have tried to run splat on Ubuntu VM, and it seems generating proper disassembly without linking issues. Does spimdisasm make use of unix shell or system features internally? I thought the package was OS-independent.
Neither spimdisasm or splat use any OS dependent feature, so it should behave the same everywhere. That said, I installed Windows 11 on a virtual machine with Python 3.11.5 and I managed to reproduce the bug. I'll try to see what causes this
Not sure that it helps, but I am unable to reproduce this issue under MSYS2 MinGW x64
on Windows 10. Python 3.11.7, I see the symbols resolved correctly:
marks@DESKTOP-AOUBO9E MINGW64 ~/TSA
$ grep -n3 8009319C asm/data/93680.rodata.s
344-/* 93D90 80093190 8001ABB8 */ .word .L8001ABB8
345-/* 93D94 80093194 8001ABF4 */ .word .L8001ABF4
346-/* 93D98 80093198 8001AC74 */ .word .L8001AC74
347:/* 93D9C 8009319C 8001ACF4 */ .word .L8001ACF4
348-/* 93DA0 800931A0 8001B1AC */ .word .L8001B1AC
349-/* 93DA4 800931A4 8001AD78 */ .word .L8001AD78
350-/* 93DA8 800931A8 8001ADB8 */ .word .L8001ADB8
marks@DESKTOP-AOUBO9E MINGW64 ~/TSA
$ grep -R jtbl_80093130 asm
asm/177F0.s:/* 1B064 8001A464 3C018009 */ lui $at, %hi(jtbl_80093130)
asm/177F0.s:/* 1B06C 8001A46C 8C383130 */ lw $t8, %lo(jtbl_80093130)($at)
asm/data/93680.rodata.s:glabel jtbl_80093130
Not sure that it helps, but I am unable to reproduce this issue under
MSYS2 MinGW x64
on Windows 10. Python 3.11.7, I see the symbols resolved correctly:marks@DESKTOP-AOUBO9E MINGW64 ~/TSA $ grep -n3 8009319C asm/data/93680.rodata.s 344-/* 93D90 80093190 8001ABB8 */ .word .L8001ABB8 345-/* 93D94 80093194 8001ABF4 */ .word .L8001ABF4 346-/* 93D98 80093198 8001AC74 */ .word .L8001AC74 347:/* 93D9C 8009319C 8001ACF4 */ .word .L8001ACF4 348-/* 93DA0 800931A0 8001B1AC */ .word .L8001B1AC 349-/* 93DA4 800931A4 8001AD78 */ .word .L8001AD78 350-/* 93DA8 800931A8 8001ADB8 */ .word .L8001ADB8 marks@DESKTOP-AOUBO9E MINGW64 ~/TSA $ grep -R jtbl_80093130 asm asm/177F0.s:/* 1B064 8001A464 3C018009 */ lui $at, %hi(jtbl_80093130) asm/177F0.s:/* 1B06C 8001A46C 8C383130 */ lw $t8, %lo(jtbl_80093130)($at) asm/data/93680.rodata.s:glabel jtbl_80093130
I think the issue is not related to the shell as long as spimdisasm and splat are not using shell internally. Have you tried to run python via cmd or anaconda prompt? This could be an unknown python bug for Windows 11 if that worked for you as well.
We (well, Anghelo) have been debugging and it looks to be due to the "long" datatype being 32 bits under Windows, but 64 bits under Linux, which causes the symbol address to be calculated incorrectly.
I didn't encounter the problem because the rabbitizer wheel was compiled locally when I pip installed, but you & Anghelo got the pre built wheel from pypi.
Watch this space for a new release...
We (well, Anghelo) have been debugging and it looks to be due to the "long" datatype being 32 bits under Windows, but 64 bits under Linux, which causes the symbol address to be calculated incorrectly.
I didn't encounter the problem because the rabbitizer wheel was compiled locally when I pip installed, but you & Anghelo got the pre built wheel from pypi.
Watch this space for a new release...
Oh it's a bug from rabbitizer. Then I would have to build it by myself and replace the long with long long?
Rabbitizer will need to be updated and released - if you want to test the fix out beforehand, you can change this line https://github.com/Decompollaborate/rabbitizer/blob/c6e988affab6790a7a497e7c68a50bb58e78e1c1/rabbitizer/rabbitizer_type_LoPairingInfo.c#L26 from T_LONG
to T_LONGLONG
and rebuild the wheel (I think pip install .
) once you've made that change.
Okay, many thanks for the help. Shall we close this issue now?
I made a new release of rabbitizer that should address this issue (https://github.com/Decompollaborate/rabbitizer/pull/51 and https://github.com/Decompollaborate/rabbitizer/pull/52)
Could you please install the latest version of rabbitizer and tell us if the issue still persists? To make sure you install the latest version you can run this:
python3 -m pip install "rabbitizer==1.8.3"
Could confirm that the issue has gone after installing the latest version of rabbitizer.
Cool! glad that it finally got solved
Hello there,
I am working a disassembly project targets N64, that make use of splat, which depends on spimdisasm. But I notice that it's generating
.L*
without.glabel .L*
, for example:in which
.L8001B1AC
is referenced in rodata:This results in undefined reference on linking the objects, as .L8001B1AC cannot be seen by the linker.
I have look into the source code of splat, where they emit asm code via:
and turns out the assembly was directly emitted by spimdisasm.
I have tried anaconda3 and standalone python 3.11.7, however both of them produced the exact same results. Hence I am wondering if I have made any mistake on config or env setup. I am using windows 11 with spimdisasm 1.20.0, and
spimdisasm.common.GlobalConfig
was:Many thanks for the help.