未验证 提交 2724b7ef 编写于 作者: J Jakob Botsch Nielsen 提交者: GitHub

Give end-marker symbols their own addresses to work around a linker bug (#66999)

It seems there is a linker bug related to control-flow guard that is
causing #66969. In eb8460fd a thunktemplates.asm file was added that has
a LEAF_END_MARKED at the end of the file. This creates two symbols for
the same upcoming address. Normally that should be fine, but in this
case it causes the linker to place the same address twice in a CFG table
in the PE file. This causes the kernel to fail while loading the image.

A simple workaround would be to add a nop at the end of
thunktemplates.asm, but @janvorli suggested giving these symbols their
own address in all cases for goodness when debugging. We already do so
for Windows x64 it looks like.

Fix #66969
上级 9cd49ff7
......@@ -52,6 +52,8 @@ C_FUNC(\Name):
C_FUNC(\Name\()_End):
.global C_FUNC(\Name\()_End)
LEAF_END \Name, \Section
// make sure this symbol gets its own address
nop
.endm
.macro NOP_6_BYTE
......
......@@ -40,6 +40,8 @@ C_FUNC(\Name):
.global C_FUNC(\Name\()_End)
C_FUNC(\Name\()_End):
LEAF_END \Name, \Section
// make sure this symbol gets its own address
nop
.endm
.macro PREPARE_EXTERNAL_VAR Name, HelperReg
......
......@@ -44,6 +44,8 @@ C_FUNC(\Name):
C_FUNC(\Name\()_End):
.global C_FUNC(\Name\()_End)
LEAF_END \Name, \Section
// make sure this symbol gets its own address
nop
.endm
.macro PREPARE_EXTERNAL_VAR Name, HelperReg
......
......@@ -33,6 +33,8 @@ C_FUNC(\Name):
C_FUNC(\Name\()_End):
.global C_FUNC(\Name\()_End)
LEAF_END \Name, \Section
// make sure this symbol gets its own address
nop
.endm
.macro PROLOG_BEG
......
......@@ -133,12 +133,13 @@ Section ends
LEAF_END_MARKED macro Name, section
public Name&_End
Name&_End label qword
Name endp
; this nop is important to keep the label in
; the right place in the face of BBT
nop
Name endp
Section ends
endm
......
......@@ -29,6 +29,9 @@ $__EndLabelName
LEAF_END $FuncName
; Make sure this symbol gets its own address
nop
MEND
;-----------------------------------------------------------------------------
......
......@@ -147,6 +147,9 @@ $__EndLabelName
LEAF_END $FuncName
; make sure this symbol gets its own address
nop
MEND
;-----------------------------------------------------------------------------
; Macro use for enabling C++ to know where to patch code at runtime.
......
......@@ -38,6 +38,8 @@ LEAF_END_MARKED macro functionName
%endMarkerName:
PUBLIC endMarkerName
functionName ENDP
; make sure this symbol gets its own address
nop
endm
PATCH_LABEL macro labelName
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册