Ticket #139 (new defect)

Opened 3 months ago

win32 safeseh is half-hearted

Reported by: appro@fy.chalmers.se Assigned to:
Priority: P1 Milestone: 0.8.0
Component: Object Format: win32/64 Version: other
Severity: normal Keywords:
Cc:

Description

Hi,

For a win32 object to be linked with microsoft link /safeseh either of following conditions has to be met: 1. .sxdata segment of info type has to be present or 2. absolute non-global symbol @feat.00 with value of 1 has to be present in symbol table. 1 doesn't prohibit 2 or vice versa.

While current version of yasm allows us to maintain .sxdata, there is no way to produce module without .sxdata, yet linkable with link /safeseh. With nasm it's trivial to achieve by adding '$@feat.00 equ 1' to source. It doesn't work with yasm, because it strips all non-global symbols [see even below]. But even if it would, it's desirable that @feat.00 is added automatically.

Even though yasm allows us to maintain .sxdata, the resulting module fails to link with "fatal error LNK1279: invalid or corrupt file: file contains invalid .sxdata contributions." This is because of following. What we find in .sxdata section are indices in object's symbol table. Symbol entry consists of 8 byte name (or offset in string table, 4 byte value, 2 byte section number, 2 byte type, 1 byte storage class and 1 byte number of aux symbols. MS link requires symbols of type 0x20 denoting a function to be listed in .sxdata segment. Failure to meet this requirement results in above mentioned LNK1279. Yasm fails to set type field to 0x20. Secondly, yasm promotes symbols registered in .sxdata to global. This is hardly appropriate, as it implies that if assembler module with private exception handler is to be included in large library, then developer has to make sure it doesn't cause naming conflict. But handler is private and a developer would find it counterintuitive and won't care to take naming into consideration. Yasm should not promote handlers' symbols to global, yet keep them in symbol table. In other words symbols table should not be stripped for all non-global symbols. There can be different strategies for this. nasm for example simple keeps all symbols, gas strips symbols named in certain way [namely starting with .L]. Yasm can choose to be adaptive and keep symbols it has to keep, such as those mentioned in safeseh directives and @feat.00. But either way would do. A lot of thanks in advance. A.

Attachments


Add/Change #139 (win32 safeseh is half-hearted)