Skip to content

Commit 57846f4

Browse files
hjl-toolsgbtucker
authored andcommitted
Properly add .note.gnu.property section to assembly codes
1. Revert "x86: Generate .note.gnu.property section for ELF output" This reverts commit 8074e3f, which is a hack to work around the old nasm which doesn't support section .note.gnu.property note alloc noexec align=8 This hack doesn't work for downstream, like: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2040091 2. If Intel CET is enabled, require nasm with note section support to add section .note.gnu.property note alloc noexec align=N to assembly codes. Verified with $ CC="gcc -Wl,-z,cet-report=error -fcf-protection" CXX="g++ -Wl,-z,cet-report=error -fcf-protection" .../configure x86_64-linux $ make -j8 on Tiger Lake. Change-Id: I6d66fe6fd054420d7fde35b1508ca9f09defdeca Signed-off-by: H.J. Lu <[email protected]>
1 parent e3783f2 commit 57846f4

File tree

5 files changed

+20
-127
lines changed

5 files changed

+20
-127
lines changed

Makefile.am

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,12 @@ test: $(addsuffix .run,$(unit_tests))
118118
@echo Completed run: $<
119119

120120
# Support for yasm/nasm/gas
121-
if INTEL_CET_ENABLED
122-
export CET_LD=$(LD)
123-
endif
124121
if USE_YASM
125-
if INTEL_CET_ENABLED
126-
as_filter = ${srcdir}/tools/yasm-cet-filter.sh
127-
else
128122
as_filter = ${srcdir}/tools/yasm-filter.sh
129123
endif
130-
endif
131124
if USE_NASM
132-
if INTEL_CET_ENABLED
133-
as_filter = ${srcdir}/tools/nasm-cet-filter.sh
134-
else
135125
as_filter = ${srcdir}/tools/nasm-filter.sh
136126
endif
137-
endif
138127
if CPU_AARCH64
139128
as_filter = $(CC) -D__ASSEMBLY__
140129
endif

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ fi
5151

5252
# Check for programs
5353
AC_PROG_CC_STDC
54-
AC_PROG_LD
5554
AC_USE_SYSTEM_EXTENSIONS
5655
AM_SILENT_RULES([yes])
5756
LT_INIT
@@ -78,6 +77,9 @@ if test x"$is_x86" = x"yes"; then
7877
intel_cet_enabled=yes],
7978
[AC_MSG_RESULT([no])
8079
intel_cet_enabled=no])
80+
AS_IF([test "x$intel_cet_enabled" = "xyes"], [
81+
AC_DEFINE(INTEL_CET_ENABLED, [1], [Intel CET enabled.])
82+
])
8183

8284

8385
# Pick an assembler yasm or nasm
@@ -261,8 +263,6 @@ else
261263
AM_CONDITIONAL(DARWIN, test "x" = "y")
262264
fi
263265

264-
AM_CONDITIONAL(INTEL_CET_ENABLED, [test x"$intel_cet_enabled" = x"yes"])
265-
266266
# Check for header files
267267
AC_CHECK_HEADERS([limits.h stdint.h stdlib.h string.h])
268268

include/reg_sizes.asm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@
195195

196196
%define XWORD(reg) reg %+ x
197197

198+
%ifdef INTEL_CET_ENABLED
199+
%ifdef __NASM_VER__
200+
%if AS_FEATURE_LEVEL >= 10
201+
%ifidn __OUTPUT_FORMAT__,elf32
202+
section .note.gnu.property note alloc noexec align=4
203+
DD 0x00000004,0x0000000c,0x00000005,0x00554e47
204+
DD 0xc0000002,0x00000004,0x00000003
205+
%endif
206+
%ifidn __OUTPUT_FORMAT__,elf64
207+
section .note.gnu.property note alloc noexec align=8
208+
DD 0x00000004,0x00000010,0x00000005,0x00554e47
209+
DD 0xc0000002,0x00000004,0x00000003,0x00000000
210+
%endif
211+
%endif
212+
%endif
213+
%endif
214+
198215
%ifidn __OUTPUT_FORMAT__,elf32
199216
section .note.GNU-stack noalloc noexec nowrite progbits
200217
section .text

tools/nasm-cet-filter.sh

Lines changed: 0 additions & 61 deletions
This file was deleted.

tools/yasm-cet-filter.sh

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)