cloudcores / CuAssembler

An unofficial cuda assembler, for all generations of SASS, hopefully :)
MIT License
361 stars 66 forks source link

Exception: ('Duplicate symbol @%#x with name %s!', 24, '') #13

Open manospavlidakis opened 1 year ago

manospavlidakis commented 1 year ago

libcublasLt_static.1028.sm_75.zip libcublasLt_static.1028.sm_75_cubin.zip I successfully create the assembly code from libcublasLt_static.1028.sm_75.cubin with cuasm libcublasLt_static.1028.sm_75.cubin. When I try to regenerate the cubin with cuasm libcublasLt_static.1028.sm_75.cuasm -o new_libcublasLt_static.1028.sm_75.cubin it shows me the following error: 2023-01-27 16:55:59,995 - - Running CuAsmParser.parse... 2023-01-27 16:55:59,996 - ENTRY - Parsing file libcublasLt_static.1028.sm_75.cuasm 2023-01-27 16:56:00,025 - - Running CuAsmParser.preScan... 2023-01-27 16:56:03,810 - - Running CuAsmParser.gatherTextSectionSizeLabel... 2023-01-27 16:56:03,814 - - Running CuAsmParser.__buildInternalTables... Traceback (most recent call last): File "/home1/public/manospavl/binary_modification/CuAssembler/bin/cuasm", line 153, in doProcess(infile, outfile, direction) File "/home1/public/manospavl/binary_modification/CuAssembler/bin/cuasm", line 94, in doProcess cuasm2cubin(src, dst) File "/home1/public/manospavl/binary_modification/CuAssembler/bin/cuasm", line 72, in cuasm2cubin cap.parse(asmname) File "/home1/public/manospavl/binary_modification/CuAssembler/CuAsm/CuAsmLogger.py", line 210, in wrapper ret = func(*args, *kwargs) File "/home1/public/manospavl/binary_modification/CuAssembler/CuAsm/CuAsmParser.py", line 766, in parse self.__buildInternalTables() File "/home1/public/manospavl/binary_modification/CuAssembler/CuAsm/CuAsmLogger.py", line 241, in wrapper ret = func(args, **kwargs) File "/home1/public/manospavl/binary_modification/CuAssembler/CuAsm/CuAsmParser.py", line 929, in buildInternalTables self.mSectionDict['.symtab'].getData()) File "/home1/public/manospavl/binary_modification/CuAssembler/CuAsm/CuAsmParser.py", line 147, in buildSymbolDict raise Exception('Duplicate symbol @%#x with name %s!', p, name) Exception: ('Duplicate symbol @%#x with name %s!', 24, '')

rindlespot commented 1 year ago

I'm no python expert, but it looks like the string for the "raise exception" instruction is badly formed. Probably should be something like:

raise Exception('Duplicate symbol @%#x with name %s!'%(p, name))

Unfortunately, changing this doesn't tell us much. Apparently name is blank. And since it's complaining about "duplicates," I guess there's 2 blank names.

I wonder if this is related to the warning message generated when you produce the cuasm file? Do you get the Currently only ET_EXEC type of elf is supported! ET_REL given message too? I'm not sure what it means, but it sounds bad.

Are you building your executable with "virtual arch" enabled? Maybe that's what ET_REL means?

cloudcores commented 1 year ago

@manospavlidakis Sorry for this late reply, but I think @rindlespot already got most of it.

As pointed by rindlespot, the exception message is just a typo, but the exception itself is CuAssembler does not support ELF with ET_REL type yet.

Currently CuAssembler only supports ELF with type ET_EXEC, which is executable format, which usually contains sections and a few segments(called program header in ELF). ELF with type ET_REL (REL means relocatable? Such as object files) have different mechanism of treating symbols and section entries, and usually no segments, which will be handled during linking into the final executable (if it is static). I found current processing of those information is not quite robust, thus support for ET_REL types is disabled.

Sorry for the inconvenience, usually we don't need to handle this type unless hacking official libraries :-)