#134 ✓resolved
Peter Johnson

win32 safeseh is half-hearted

Reported by Peter Johnson | June 25th, 2011 @ 07:50 PM | in 0.8.0 (closed)

Originally posted on Trac by appro@fy.chalmers.se
Original Trac Ticket

  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.

Trac Attachments

h3. Trac Comments
comment:1

              Changed 11 months ago by jlebar@mozilla.com


We'd also really like this at Mozilla.  Right now, we can't use yasm on Windows, so we instead translate libvpx's assembly to masm syntax.  We're running into similar problems trying to use yasm to assemble libjpeg-turbo.

I'm happy to help make this happen, although it's definitely out of my depth.

I'd include a link to the relevant bug, but trac doesn't like that.  Instead, I'll direct the curious to Mozilla bug 573948, comment 57.

comment:2

              Changed 11 months ago by peter@tortall.net


      comment:2

                  Changed 11 months ago by peter@tortall.net

      Owner
        set to peter@tortall.net
    
      Status
        changed from new to assigned

      Owner
        set to peter@tortall.net
    
      Status
        changed from new to assigned

comment:3

              Changed 11 months ago by peter


(In [2343]) Fix #139: Fix a number of issues with win32 safeseh support.

Always create a non-global absolute symbol @feat.00 with value of 1.
Set type field to 0x20 (function) for safeseh-declared symbols.
Force safeseh-declared symbols into the symbol table, but don't force
them to be global.

      comment:3

                  Changed 11 months ago by peter

      Status
        changed from assigned to closed
    
      Resolution
        set to fixed

(In [2343]) Fix #139: Fix a number of issues with win32 safeseh support.

Always create a non-global absolute symbol @feat.00 with value of 1.
Set type field to 0x20 (function) for safeseh-declared symbols.
Force safeseh-declared symbols into the symbol table, but don't force
them to be global.

      Status
        changed from assigned to closed
    
      Resolution
        set to fixed

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Yasm Modular Assembler Project

Shared Ticket Bins

People watching this ticket

Pages