[boost] [context] msvc /SAFESEH

171 views
Skip to first unread message

Jeff Flinn

unread,
Oct 1, 2013, 9:58:30 AM10/1/13
to bo...@lists.boost.org
I need to build my application with /SAFESEH which uses boost coroutine
which uses context. I'm getting the following link errors:

1>libboost_context-vc100-mt-gd-1_53.lib(jump_i386_ms_pe_masm.obj) :
error LNK2026: module unsafe for SAFESEH image.
1>libboost_context-vc100-mt-gd-1_53.lib(make_i386_ms_pe_masm.obj) :
error LNK2026: module unsafe for SAFESEH image.

I've built boost static libs with the same MSVC vesion and options (sans
/SAFESEH as it's not a compile/lib option)

Compiler/linker versions:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01
for 80x86
Microsoft (R) Incremental Linker Version 10.00.40219.01

Has anyone run into this and resolved the error? Any insight is appreciated.

Thanks, Jeff


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Oliver Kowalke

unread,
Oct 1, 2013, 1:12:55 PM10/1/13
to boost
Currently it is not supported, e.g. you could try to set the SAFESEH in the
masm command line (build/Jamfile).
Please report what happened.


2013/10/1 Jeff Flinn <jeffre...@gmail.com>

> I need to build my application with /SAFESEH which uses boost coroutine
> which uses context. I'm getting the following link errors:
>
> 1>libboost_context-vc100-mt-**gd-1_53.lib(jump_i386_ms_pe_**masm.obj) :
> error LNK2026: module unsafe for SAFESEH image.
> 1>libboost_context-vc100-mt-**gd-1_53.lib(make_i386_ms_pe_**masm.obj) :
> error LNK2026: module unsafe for SAFESEH image.
>
> I've built boost static libs with the same MSVC vesion and options (sans
> /SAFESEH as it's not a compile/lib option)
>
> Compiler/linker versions:
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for
> 80x86
> Microsoft (R) Incremental Linker Version 10.00.40219.01
>
> Has anyone run into this and resolved the error? Any insight is
> appreciated.
>
> Thanks, Jeff
>
>
> ______________________________**_________________
> Unsubscribe & other changes: http://lists.boost.org/**
> mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>

Oliver Kowalke

unread,
Oct 1, 2013, 1:14:32 PM10/1/13
to boost
masm /safeseh


2013/10/1 Oliver Kowalke <oliver....@gmail.com>

> Currently it is not supported, e.g. you could try to set the SAFESEH in
> the masm command line (build/Jamfile).
> Please report what happened.
>
>
> 2013/10/1 Jeff Flinn <jeffre...@gmail.com>
>
>> I need to build my application with /SAFESEH which uses boost coroutine
>> which uses context. I'm getting the following link errors:
>>
>> 1>libboost_context-vc100-mt-**gd-1_53.lib(jump_i386_ms_pe_**masm.obj) :
>> error LNK2026: module unsafe for SAFESEH image.
>> 1>libboost_context-vc100-mt-**gd-1_53.lib(make_i386_ms_pe_**masm.obj) :
>> error LNK2026: module unsafe for SAFESEH image.
>>
>> I've built boost static libs with the same MSVC vesion and options (sans
>> /SAFESEH as it's not a compile/lib option)
>>
>> Compiler/linker versions:
>> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01for 80x86

Jeff Flinn

unread,
Oct 1, 2013, 1:34:27 PM10/1/13
to bo...@lists.boost.org
On 10/1/2013 1:12 PM, Oliver Kowalke wrote:
> Currently it is not supported, e.g. you could try to set the SAFESEH in the
> masm command line (build/Jamfile).
> Please report what happened.

I've added /safeseh in ...\boost_1_53_0\libs\context\build\Jamfile.v2:

actions masm
{
ml /safeseh /c /Fo"$(<)" "$(>)"
}

And get the same link errors:
>>
>> 1>libboost_context-vc100-mt-**gd-1_53.lib(jump_i386_ms_pe_**masm.obj) :
>> error LNK2026: module unsafe for SAFESEH image.
>> 1>libboost_context-vc100-mt-**gd-1_53.lib(make_i386_ms_pe_**masm.obj) :
>> error LNK2026: module unsafe for SAFESEH image.

/VERBOSE:SAFESEH provides no futher information.

Let me know if you have any other ideas to try.

Jeff

Oliver Kowalke

unread,
Oct 1, 2013, 1:47:16 PM10/1/13
to boost
2013/10/1 Jeff Flinn <jeffre...@gmail.com>

> And get the same link errors:
>

hmm - then it needs some modifications in the assembler files I fear that
the MSDN does not well document it.

Jeff Flinn

unread,
Oct 1, 2013, 3:10:11 PM10/1/13
to bo...@lists.boost.org
It's appearing that

actions masm
{
ml /safeseh /c /Fo"$(<)" "$(>)"
}

is being ignored in \boost_1_53_0\libs\context\build\Jamfile.v2.

I added:

MyHandler proc
.safeseh MyHandler
MyHandler endp

to make_i386_ms_pe_masm.asm resulting in the following error:

msvc.compile.asm
bin.v2\libs\context\build\msvc-10.0\debug\link-static\runtime-link-static\threading-multi\asm\make_i386_ms_pe_masm.obj

Assembling: libs\context\src\asm\make_i386_ms_pe_masm.asm

libs\context\src\asm\make_i386_ms_pe_masm.asm(50) : warning
A4024:directive ignored without /safeseh switch

msvc.compile.asm
bin.v2\libs\context\build\msvc-10.0\debug\link-static\runtime-link-static\threading-multi\asm\jump_i386_ms_pe_masm.obj

But running

ml /safeseh /c make_i386_ms_pe_masm.asm

in ...\boost_1_53_0\libs\context\src\asm

succeeds.

Jeff

Jeff Flinn

unread,
Oct 1, 2013, 3:38:01 PM10/1/13
to bo...@lists.boost.org
On 10/1/2013 1:47 PM, Oliver Kowalke wrote:
> 2013/10/1 Jeff Flinn <jeffre...@gmail.com>
>
>> And get the same link errors:
>>
>
> hmm - then it needs some modifications in the assembler files I fear that
> the MSDN does not well document it.

Ok I'm able to build my app linking with static context libs.

I had to manually assemble the following into obj's by:

ml /safeseh /c make_i386_ms_pe_masm.asm
ml /safeseh /c jump_i386_ms_pe_masm.asm

and then replace

make_i386_ms_pe_masm.obj
jump_i386_ms_pe_masm.obj

in the boost build generated libs with the above.

Any idea why modifying ...\boost_1_53_0\libs\context\build\Jamfile.v2:

actions masm
{
ml /safeseh /c /Fo"$(<)" "$(>)"
}

is not being honored?

Jeff

Oliver Kowalke

unread,
Oct 1, 2013, 4:26:16 PM10/1/13
to boost
2013/10/1 Jeff Flinn <jeffre...@gmail.com>

> On 10/1/2013 1:47 PM, Oliver Kowalke wrote:
>
>> 2013/10/1 Jeff Flinn <jeffre...@gmail.com>
>>
>> And get the same link errors:
>>>
>>>
>> hmm - then it needs some modifications in the assembler files I fear that
>> the MSDN does not well document it.
>>
>
> Ok I'm able to build my app linking with static context libs.
>
> I had to manually assemble the following into obj's by:
>
> ml /safeseh /c make_i386_ms_pe_masm.asm
> ml /safeseh /c jump_i386_ms_pe_masm.asm
>
> and then replace
>
> make_i386_ms_pe_masm.obj
> jump_i386_ms_pe_masm.obj
>
> in the boost build generated libs with the above.
>
> Any idea why modifying ...\boost_1_53_0\libs\context\**build\Jamfile.v2:
>
>
> actions masm
> {
> ml /safeseh /c /Fo"$(<)" "$(>)"
> }
>
> is not being honored?
>

I remember that boost.build has a bug which causes this behaviour - I don't
know when it will be fixed (if ever) or we have to wait for cmake.

Tobias Loew

unread,
Aug 24, 2014, 7:00:03 AM8/24/14
to bo...@lists.boost.org
Hi,

I had the same problem (with version 1.56) and I solved adding /safeseh in
boost_1_56_0\libs\context\build\Jamfile.v2 as supposed:

actions masm
{
ml /safeseh /c /Fo"$(<)" "$(>)"
}


and -safeseh in boost_1_56_0\tools\build\src\tools\msvc.jam, line 952:

local default-assembler-i386 = "ml -coff -safeseh" ;

Maybe someone can explain, why this works?

Tobias



--
View this message in context: http://boost.2283326.n4.nabble.com/context-msvc-SAFESEH-tp4652245p4666842.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Tobias Loew

unread,
Aug 12, 2015, 6:36:47 AM8/12/15
to bo...@lists.boost.org
I found a solution here http://lists.boost.org/boost-build/2013/10/27024.php
<http://lists.boost.org/boost-build/2013/10/27024.php> that solves the
problem entirely from the b2.exe command-line. Just add

asmflags=\safeseh

My full b2.exe command-line looks like this:

.\b2.exe --toolset=msvc-11.0 variant=debug,release
runtime-link=shared,static address-model=32 asmflags=\safeseh
--stagedir=.\stage\i386

Tobias



--
View this message in context: http://boost.2283326.n4.nabble.com/context-msvc-SAFESEH-tp4652245p4678770.html
Reply all
Reply to author
Forward
0 new messages