| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2014 Google Inc. All rights reserved. | 3 # Copyright (c) 2014 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """ | 7 """ |
| 8 Make sure safeseh setting is extracted properly. | 8 Make sure safeseh setting is extracted properly. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import TestGyp | 11 import TestGyp |
| 12 | 12 |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 if sys.platform == 'win32': | 15 if sys.platform == 'win32': |
| 16 test = TestGyp.TestGyp() | 16 test = TestGyp.TestGyp(formats=['ninja']) |
| 17 | 17 |
| 18 CHDIR = 'linker-flags' | 18 CHDIR = 'linker-flags' |
| 19 test.run_gyp('safeseh.gyp', chdir=CHDIR) | 19 test.run_gyp('safeseh.gyp', chdir=CHDIR) |
| 20 test.build('safeseh.gyp', test.ALL, chdir=CHDIR) | 20 test.build('safeseh.gyp', test.ALL, chdir=CHDIR) |
| 21 | 21 |
| 22 def HasSafeExceptionHandlers(exe): | 22 def HasSafeExceptionHandlers(exe): |
| 23 full_path = test.built_file_path(exe, chdir=CHDIR) | 23 full_path = test.built_file_path(exe, chdir=CHDIR) |
| 24 output = test.run_dumpbin('/LOADCONFIG', full_path) | 24 output = test.run_dumpbin('/LOADCONFIG', full_path) |
| 25 return ' Safe Exception Handler Table' in output | 25 return ' Safe Exception Handler Table' in output |
| 26 | 26 |
| 27 # From MSDN: http://msdn.microsoft.com/en-us/library/9a89h429.aspx | 27 # From MSDN: http://msdn.microsoft.com/en-us/library/9a89h429.aspx |
| 28 # If /SAFESEH is not specified, the linker will produce an image with a | 28 # If /SAFESEH is not specified, the linker will produce an image with a |
| 29 # table of safe exceptions handlers if all modules are compatible with | 29 # table of safe exceptions handlers if all modules are compatible with |
| 30 # the safe exception handling feature. If any modules were not | 30 # the safe exception handling feature. If any modules were not |
| 31 # compatible with safe exception handling feature, the resulting image | 31 # compatible with safe exception handling feature, the resulting image |
| 32 # will not contain a table of safe exception handlers. | 32 # will not contain a table of safe exception handlers. |
| 33 # However, the msvs IDE passes /SAFESEH to the linker by default, if | 33 if HasSafeExceptionHandlers('test_safeseh_default.exe'): |
| 34 # ImageHasSafeExceptionHandlers is not set to false in the vcxproj file. | |
| 35 # We emulate this behavior in msvs_emulation.py, so 'test_safeseh_default' | |
| 36 # and 'test_safeseh_yes' are built identically. | |
| 37 if not HasSafeExceptionHandlers('test_safeseh_default.exe'): | |
| 38 test.fail_test() | 34 test.fail_test() |
| 39 if HasSafeExceptionHandlers('test_safeseh_no.exe'): | 35 if HasSafeExceptionHandlers('test_safeseh_no.exe'): |
| 40 test.fail_test() | 36 test.fail_test() |
| 41 if not HasSafeExceptionHandlers('test_safeseh_yes.exe'): | 37 if not HasSafeExceptionHandlers('test_safeseh_yes.exe'): |
| 42 test.fail_test() | 38 test.fail_test() |
| 43 | 39 |
| 44 test.pass_test() | 40 test.pass_test() |
| OLD | NEW |