I'm considering to add support for the COFF COMDAT section attribute (IMAGE_SCN_LNK_COMDAT).
However, I didn't find any documentation about how the contents of field IMAGE_AUX_SYMBOL.Section.CheckSum is supposed to be calculated. This info is required for COMDATs.
Perhaps anybody has an idea - I already checked FASM/NASM/YASM docs with no luck.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've also searched the web but google just spits out nothing relevant.
The only thing I've found is a thread in the flat asm forums.
If you've also ment with "docs" the forums of FASM/NASM/YASM then you'll know this thread.
At the end he (the poster) sticked at the same point as you are now.
What's up with GCC or Open Watcom ? Do they support COMDAT ? Maybe the sources can offer the algorithm …
Very strange that there is no such information/documentation in the web, is it such a secret ?!
That makes it very hard to help you. Pitiful, because I wish to be able to give something back to you for that what you are giving us …
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OW's compiler's support OMF only. The OW linker WLINK ( and JWLINK! ) don't support COFF COMDATs currently. In fact, their incapability triggered my interest in this subject - there are a few MS libraries ( i.e. DXGUID.LIB ) that contain COMDATs and currently you have to avoid (J)WLINK if such libraries are to be used.
GCC might be better - but I won't use GNU code in JWasm.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did some "investigating"… to help of course…
MS C++ compiler calls MSPDBxxx!SigForPbCb for every instruction in the COMDAT section.
SigForPbCb is nothing more than a CRC32 function with omitted bit inversion.
You don't need to call CRC32 for every instruction just call CRC32(section,len,0)
Here is code:
.data
align 16
CRC32Table label dword
i = 0
crc = i
WHILE i LT 256
crc = i
REPT 8
crc = (crc shr 1) xor (0EDB88320h * (crc and 1))
ENDM
DD crc
i = i + 1
ENDM
.code
; MSPDBxx!SigForPbCb
CRC32COMDAT proc lpBuffer:DWORD, dwBufLen:DWORD, dwCRC:DWORD
mov edx,lpBuffer
mov ecx,dwBufLen
mov eax,dwCRC
add edx,ecx
push esi
neg ecx
mov esi,edx
jz @F; Len = 0
.repeat
xor edx,edx
mov dl,
xor dl,al
shr eax,8
xor eax,
inc ecx
.until zero?
@@: pop esi
ret
CRC32COMDAT endp
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm considering to add support for the COFF COMDAT section attribute (IMAGE_SCN_LNK_COMDAT).
However, I didn't find any documentation about how the contents of field IMAGE_AUX_SYMBOL.Section.CheckSum is supposed to be calculated. This info is required for COMDATs.
Perhaps anybody has an idea - I already checked FASM/NASM/YASM docs with no luck.
Hello Sr japheth, I have found some info in this book:
Common Language Infrastructure Annotated Standard, The
By Jim Miller, Susann Ragsdale
Hi Japheth,
I just sent some source code to your (site) email address.
If this is what you're looking for, a more detailed explanation is available at
http://www.codeproject.com/KB/cpp/PEChecksum.aspx
Hope this helps, /Ph.
I've also searched the web but google just spits out nothing relevant.
The only thing I've found is a thread in the flat asm forums.
If you've also ment with "docs" the forums of FASM/NASM/YASM then you'll know this thread.
At the end he (the poster) sticked at the same point as you are now.
http://board.flatassembler.net/topic.php?t=4706
But maybe Thomas has implemented it in FASM and you can ask him ?
Regards
Greenhorn
I'm aware of the discussion in the FASM forum. AFAICS the feature isn't implemented yet in FASM.
There's also a request to support COFF COMDAT for YASM, but there's also no implementation yet.
I'm about to test if the PE checksum algorithm can be used for COMDAT checksums as well, but I'm not too optimistic.
What's up with GCC or Open Watcom ? Do they support COMDAT ? Maybe the sources can offer the algorithm …
Very strange that there is no such information/documentation in the web, is it such a secret ?!
That makes it very hard to help you. Pitiful, because I wish to be able to give something back to you for that what you are giving us …
OW's compiler's support OMF only. The OW linker WLINK ( and JWLINK! ) don't support COFF COMDATs currently. In fact, their incapability triggered my interest in this subject - there are a few MS libraries ( i.e. DXGUID.LIB ) that contain COMDATs and currently you have to avoid (J)WLINK if such libraries are to be used.
GCC might be better - but I won't use GNU code in JWasm.
I've found something about COMDAT in DWARF, maybe this gives you an idea …
http://wiki.dwarfstd.org/index.php?title=COMDAT_Type_Sections#Computing_a_Type_Signature
Regards
Hello,
I did some "investigating"… to help of course…
MS C++ compiler calls MSPDBxxx!SigForPbCb for every instruction in the COMDAT section.
SigForPbCb is nothing more than a CRC32 function with omitted bit inversion.
You don't need to call CRC32 for every instruction just call CRC32(section,len,0)
Here is code:
.data
align 16
CRC32Table label dword
i = 0
crc = i
WHILE i LT 256
crc = i
REPT 8
crc = (crc shr 1) xor (0EDB88320h * (crc and 1))
ENDM
DD crc
i = i + 1
ENDM
.code
; MSPDBxx!SigForPbCb
CRC32COMDAT proc lpBuffer:DWORD, dwBufLen:DWORD, dwCRC:DWORD
mov edx,lpBuffer
mov ecx,dwBufLen
mov eax,dwCRC
add edx,ecx
push esi
neg ecx
mov esi,edx
jz @F; Len = 0
.repeat
xor edx,edx
mov dl,
xor dl,al
shr eax,8
xor eax,
inc ecx
.until zero?
@@: pop esi
ret
CRC32COMDAT endp
Great, drizzz! I'll check this out ASAP.
Support for COMDAT won't be included in v2.07. I'm going to implement this support in jwlink first.
Support for COMDAT is added in jwasm v2.10.
>. I'm going to implement this support in jwlink first.
jwlink currently does NOT support COMDAT sections as of yet.