mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Joao Moreira <joao.moreira@intel.com>
To: musl@lists.openwall.com
Subject: [musl] [PATCH 4/4] Add endbr32 to i386 assembly functions
Date: Mon, 19 Oct 2020 15:43:42 -0700	[thread overview]
Message-ID: <20201019224342.53303-5-joao.moreira@intel.com> (raw)
In-Reply-To: <20201019224342.53303-1-joao.moreira@intel.com>

Include ibt.s file in i386 assembly files. This file contains the macro
definitions for endbr32 instructions and is placed in the beginning of each
assembly function. If CET_IBT is not defined for compilation, the macro is
defined to nothing and the generated binary is not affected.

Signed-off-by: Joao Moreira <joao.moreira@intel.com>
---
 crt/i386/crti.s                     |  4 ++++
 crt/i386/crtn.s                     |  4 ++++
 src/fenv/i386/fenv.s                | 13 +++++++++++--
 src/ldso/i386/dlsym.s               |  3 +++
 src/ldso/i386/tlsdesc.s             |  4 ++++
 src/math/i386/acos.s                |  2 ++
 src/math/i386/acosf.s               |  3 +++
 src/math/i386/acosl.s               |  3 +++
 src/math/i386/asin.s                |  3 +++
 src/math/i386/asinf.s               |  3 +++
 src/math/i386/asinl.s               |  3 +++
 src/math/i386/atan.s                |  3 +++
 src/math/i386/atan2.s               |  3 +++
 src/math/i386/atan2f.s              |  3 +++
 src/math/i386/atan2l.s              |  3 +++
 src/math/i386/atanf.s               |  3 +++
 src/math/i386/atanl.s               |  2 ++
 src/math/i386/exp_ld.s              |  4 ++++
 src/math/i386/expl.s                |  2 ++
 src/math/i386/floor.s               | 11 +++++++++++
 src/math/i386/hypot.s               |  3 +++
 src/math/i386/hypotf.s              |  3 +++
 src/math/i386/log.s                 |  3 +++
 src/math/i386/log10.s               |  3 +++
 src/math/i386/log10f.s              |  3 +++
 src/math/i386/log10l.s              |  3 +++
 src/math/i386/log1p.s               |  3 +++
 src/math/i386/log1pf.s              |  3 +++
 src/math/i386/log1pl.s              |  3 +++
 src/math/i386/log2.s                |  3 +++
 src/math/i386/log2f.s               |  3 +++
 src/math/i386/log2l.s               |  3 +++
 src/math/i386/logf.s                |  3 +++
 src/math/i386/logl.s                |  3 +++
 src/math/i386/remquo.s              |  5 +++++
 src/math/i386/scalbn.s              |  5 +++++
 src/math/i386/scalbnf.s             |  5 +++++
 src/math/i386/scalbnl.s             |  5 +++++
 src/process/i386/vfork.s            |  3 +++
 src/setjmp/i386/longjmp.s           |  3 +++
 src/setjmp/i386/setjmp.s            |  3 +++
 src/signal/i386/restore.s           |  4 ++++
 src/signal/i386/sigsetjmp.s         |  3 +++
 src/string/i386/memcpy.s            |  3 +++
 src/string/i386/memmove.s           |  3 +++
 src/string/i386/memset.s            |  7 +++++--
 src/thread/i386/__set_thread_area.s |  3 +++
 src/thread/i386/__unmapself.s       |  3 +++
 src/thread/i386/clone.s             |  3 +++
 src/thread/i386/syscall_cp.s        |  3 +++
 src/thread/i386/tls.s               |  3 +++
 51 files changed, 181 insertions(+), 4 deletions(-)

diff --git a/crt/i386/crti.s b/crt/i386/crti.s
index d2682a20..9db4dd9c 100644
--- a/crt/i386/crti.s
+++ b/crt/i386/crti.s
@@ -1,9 +1,13 @@
+.include "ibt.s"
+
 .section .init
 .global _init
 _init:
+	ENDBRANCH32
 	sub $12,%esp
 
 .section .fini
 .global _fini
 _fini:
+	ENDBRANCH32
 	sub $12,%esp
diff --git a/crt/i386/crtn.s b/crt/i386/crtn.s
index f3b61e01..6010ec16 100644
--- a/crt/i386/crtn.s
+++ b/crt/i386/crtn.s
@@ -1,7 +1,11 @@
+.include "ibt.s"
+
 .section .init
+	ENDBRANCH32
 	add $12,%esp
 	ret
 
 .section .fini
+	ENDBRANCH32
 	add $12,%esp
 	ret
diff --git a/src/fenv/i386/fenv.s b/src/fenv/i386/fenv.s
index e7f7932a..1da507a5 100644
--- a/src/fenv/i386/fenv.s
+++ b/src/fenv/i386/fenv.s
@@ -1,8 +1,11 @@
+.include "ibt.s"
+
 .hidden __hwcap
 
 .global feclearexcept
 .type feclearexcept,@function
-feclearexcept:	
+feclearexcept:
+	ENDBRANCH32
 	mov 4(%esp),%ecx
 	and $0x3f,%ecx
 	fnstsw %ax
@@ -49,7 +52,8 @@ feclearexcept:
 
 .global feraiseexcept
 .type feraiseexcept,@function
-feraiseexcept:	
+feraiseexcept
+	ENDBRANCH32
 	mov 4(%esp),%eax
 	and $0x3f,%eax
 	sub $32,%esp
@@ -64,6 +68,7 @@ feraiseexcept:
 .hidden __fesetround
 .type __fesetround,@function
 __fesetround:
+	ENDBRANCH32
 	mov 4(%esp),%ecx
 	push %eax
 	xor %eax,%eax
@@ -88,6 +93,7 @@ __fesetround:
 .global fegetround
 .type fegetround,@function
 fegetround:
+	ENDBRANCH32
 	push %eax
 	fnstcw (%esp)
 	pop %eax
@@ -97,6 +103,7 @@ fegetround:
 .global fegetenv
 .type fegetenv,@function
 fegetenv:
+	ENDBRANCH32
 	mov 4(%esp),%ecx
 	xor %eax,%eax
 	fnstenv (%ecx)
@@ -116,6 +123,7 @@ fegetenv:
 .global fesetenv
 .type fesetenv,@function
 fesetenv:
+	ENDBRANCH32
 	mov 4(%esp),%ecx
 	xor %eax,%eax
 	inc %ecx
@@ -149,6 +157,7 @@ fesetenv:
 .global fetestexcept
 .type fetestexcept,@function
 fetestexcept:
+	ENDBRANCH32
 	mov 4(%esp),%ecx
 	and $0x3f,%ecx
 	fnstsw %ax
diff --git a/src/ldso/i386/dlsym.s b/src/ldso/i386/dlsym.s
index 097e30ce..5dfa182d 100644
--- a/src/ldso/i386/dlsym.s
+++ b/src/ldso/i386/dlsym.s
@@ -1,8 +1,11 @@
+.include "ibt.s"
+
 .text
 .global dlsym
 .hidden __dlsym
 .type dlsym,@function
 dlsym:
+	ENDBRANCH32
 	push (%esp)
 	push 12(%esp)
 	push 12(%esp)
diff --git a/src/ldso/i386/tlsdesc.s b/src/ldso/i386/tlsdesc.s
index 32c81766..09f6474e 100644
--- a/src/ldso/i386/tlsdesc.s
+++ b/src/ldso/i386/tlsdesc.s
@@ -1,8 +1,11 @@
+.include "ibt.s"
+
 .text
 .global __tlsdesc_static
 .hidden __tlsdesc_static
 .type __tlsdesc_static,@function
 __tlsdesc_static:
+	ENDBRANCH32
 	mov 4(%eax),%eax
 	ret
 
@@ -10,6 +13,7 @@ __tlsdesc_static:
 .hidden __tlsdesc_dynamic
 .type __tlsdesc_dynamic,@function
 __tlsdesc_dynamic:
+	ENDBRANCH32
 	mov 4(%eax),%eax
 	push %edx
 	mov %gs:4,%edx
diff --git a/src/math/i386/acos.s b/src/math/i386/acos.s
index af423a2f..f3a975b5 100644
--- a/src/math/i386/acos.s
+++ b/src/math/i386/acos.s
@@ -1,8 +1,10 @@
+.include "ibt.s"
 # use acos(x) = atan2(fabs(sqrt((1-x)*(1+x))), x)
 
 .global acos
 .type acos,@function
 acos:
+	ENDBRANCH32
 	fldl 4(%esp)
 	fld %st(0)
 	fld1
diff --git a/src/math/i386/acosf.s b/src/math/i386/acosf.s
index d2cdfdbf..697b1255 100644
--- a/src/math/i386/acosf.s
+++ b/src/math/i386/acosf.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global acosf
 .type acosf,@function
 acosf:
+	ENDBRANCH32
 	flds 4(%esp)
 	fld %st(0)
 	fld1
diff --git a/src/math/i386/acosl.s b/src/math/i386/acosl.s
index 599c8230..d455a9a9 100644
--- a/src/math/i386/acosl.s
+++ b/src/math/i386/acosl.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global acosl
 .type acosl,@function
 acosl:
+	ENDBRANCH32
 	fldt 4(%esp)
 	fld %st(0)
 	fld1
diff --git a/src/math/i386/asin.s b/src/math/i386/asin.s
index 2bc8356f..bec105d1 100644
--- a/src/math/i386/asin.s
+++ b/src/math/i386/asin.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global asin
 .type asin,@function
 asin:
+	ENDBRANCH32
 	fldl 4(%esp)
 	mov 8(%esp),%eax
 	add %eax,%eax
diff --git a/src/math/i386/asinf.s b/src/math/i386/asinf.s
index 05909753..28b59e61 100644
--- a/src/math/i386/asinf.s
+++ b/src/math/i386/asinf.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global asinf
 .type asinf,@function
 asinf:
+	ENDBRANCH32
 	flds 4(%esp)
 	mov 4(%esp),%eax
 	add %eax,%eax
diff --git a/src/math/i386/asinl.s b/src/math/i386/asinl.s
index e973fc85..d1a0a0ae 100644
--- a/src/math/i386/asinl.s
+++ b/src/math/i386/asinl.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global asinl
 .type asinl,@function
 asinl:
+	ENDBRANCH32
 	fldt 4(%esp)
 	fld %st(0)
 	fld1
diff --git a/src/math/i386/atan.s b/src/math/i386/atan.s
index 2c57f6b3..caf27242 100644
--- a/src/math/i386/atan.s
+++ b/src/math/i386/atan.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global atan
 .type atan,@function
 atan:
+	ENDBRANCH32
 	fldl 4(%esp)
 	mov 8(%esp),%eax
 	add %eax,%eax
diff --git a/src/math/i386/atan2.s b/src/math/i386/atan2.s
index 8bc441b1..fc8ac07a 100644
--- a/src/math/i386/atan2.s
+++ b/src/math/i386/atan2.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global atan2
 .type atan2,@function
 atan2:
+	ENDBRANCH32
 	fldl 4(%esp)
 	fldl 12(%esp)
 	fpatan
diff --git a/src/math/i386/atan2f.s b/src/math/i386/atan2f.s
index 3908c86d..6e52276a 100644
--- a/src/math/i386/atan2f.s
+++ b/src/math/i386/atan2f.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global atan2f
 .type atan2f,@function
 atan2f:
+	ENDBRANCH32
 	flds 4(%esp)
 	flds 8(%esp)
 	fpatan
diff --git a/src/math/i386/atan2l.s b/src/math/i386/atan2l.s
index adf6e10a..34640836 100644
--- a/src/math/i386/atan2l.s
+++ b/src/math/i386/atan2l.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global atan2l
 .type atan2l,@function
 atan2l:
+	ENDBRANCH32
 	fldt 4(%esp)
 	fldt 16(%esp)
 	fpatan
diff --git a/src/math/i386/atanf.s b/src/math/i386/atanf.s
index c2cbe2e0..a9064b2c 100644
--- a/src/math/i386/atanf.s
+++ b/src/math/i386/atanf.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global atanf
 .type atanf,@function
 atanf:
+	ENDBRANCH32
 	flds 4(%esp)
 	mov 4(%esp),%eax
 	add %eax,%eax
diff --git a/src/math/i386/atanl.s b/src/math/i386/atanl.s
index c508bc46..4200304f 100644
--- a/src/math/i386/atanl.s
+++ b/src/math/i386/atanl.s
@@ -1,6 +1,8 @@
+.include "ibt.s"
 .global atanl
 .type atanl,@function
 atanl:
+	ENDBRANCH32
 	fldt 4(%esp)
 	fld1
 	fpatan
diff --git a/src/math/i386/exp_ld.s b/src/math/i386/exp_ld.s
index 99cba01f..93256fac 100644
--- a/src/math/i386/exp_ld.s
+++ b/src/math/i386/exp_ld.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global expm1l
 .type expm1l,@function
 expm1l:
+	ENDBRANCH32
 	fldt 4(%esp)
 	fldl2e
 	fmulp
@@ -38,6 +41,7 @@ expm1l:
 .type exp2l,@function
 exp2l:
 __exp2l:
+	ENDBRANCH32
 	fldt 4(%esp)
 1:	sub $12,%esp
 	fld %st(0)
diff --git a/src/math/i386/expl.s b/src/math/i386/expl.s
index b5124e8f..6e6b8814 100644
--- a/src/math/i386/expl.s
+++ b/src/math/i386/expl.s
@@ -1,3 +1,4 @@
+.include "ibt.s"
 # exp(x) = 2^hi + 2^hi (2^lo - 1)
 # where hi+lo = log2e*x with 128bit precision
 # exact log2e*x calculation depends on nearest rounding mode
@@ -6,6 +7,7 @@
 .global expl
 .type expl,@function
 expl:
+	ENDBRANCH32
 	fldt 4(%esp)
 
 		# interesting case: 0x1p-32 <= |x| < 16384
diff --git a/src/math/i386/floor.s b/src/math/i386/floor.s
index 46ba88db..d5360a95 100644
--- a/src/math/i386/floor.s
+++ b/src/math/i386/floor.s
@@ -1,18 +1,23 @@
+.include "ibt.s"
+
 .global floorf
 .type floorf,@function
 floorf:
+	ENDBRANCH32
 	flds 4(%esp)
 	jmp 1f
 
 .global floorl
 .type floorl,@function
 floorl:
+	ENDBRANCH32
 	fldt 4(%esp)
 	jmp 1f
 
 .global floor
 .type floor,@function
 floor:
+	ENDBRANCH32
 	fldl 4(%esp)
 1:	mov $0x7,%al
 1:	fstcw 4(%esp)
@@ -27,6 +32,7 @@ floor:
 .global ceil
 .type ceil,@function
 ceil:
+	ENDBRANCH32
 	fldl 4(%esp)
 	mov $0xb,%al
 	jmp 1b
@@ -34,6 +40,7 @@ ceil:
 .global ceilf
 .type ceilf,@function
 ceilf:
+	ENDBRANCH32
 	flds 4(%esp)
 	mov $0xb,%al
 	jmp 1b
@@ -41,6 +48,7 @@ ceilf:
 .global ceill
 .type ceill,@function
 ceill:
+	ENDBRANCH32
 	fldt 4(%esp)
 	mov $0xb,%al
 	jmp 1b
@@ -48,6 +56,7 @@ ceill:
 .global trunc
 .type trunc,@function
 trunc:
+	ENDBRANCH32
 	fldl 4(%esp)
 	mov $0xf,%al
 	jmp 1b
@@ -55,6 +64,7 @@ trunc:
 .global truncf
 .type truncf,@function
 truncf:
+	ENDBRANCH32
 	flds 4(%esp)
 	mov $0xf,%al
 	jmp 1b
@@ -62,6 +72,7 @@ truncf:
 .global truncl
 .type truncl,@function
 truncl:
+	ENDBRANCH32
 	fldt 4(%esp)
 	mov $0xf,%al
 	jmp 1b
diff --git a/src/math/i386/hypot.s b/src/math/i386/hypot.s
index 299c2e18..c7859075 100644
--- a/src/math/i386/hypot.s
+++ b/src/math/i386/hypot.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global hypot
 .type hypot,@function
 hypot:
+	ENDBRANCH32
 	mov 8(%esp),%eax
 	mov 16(%esp),%ecx
 	add %eax,%eax
diff --git a/src/math/i386/hypotf.s b/src/math/i386/hypotf.s
index 068935e2..bf3162d7 100644
--- a/src/math/i386/hypotf.s
+++ b/src/math/i386/hypotf.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global hypotf
 .type hypotf,@function
 hypotf:
+	ENDBRANCH32
 	mov 4(%esp),%eax
 	mov 8(%esp),%ecx
 	add %eax,%eax
diff --git a/src/math/i386/log.s b/src/math/i386/log.s
index 08c59924..fadd46e8 100644
--- a/src/math/i386/log.s
+++ b/src/math/i386/log.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log
 .type log,@function
 log:
+	ENDBRANCH32
 	fldln2
 	fldl 4(%esp)
 	fyl2x
diff --git a/src/math/i386/log10.s b/src/math/i386/log10.s
index 120e91ec..3facf5fc 100644
--- a/src/math/i386/log10.s
+++ b/src/math/i386/log10.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log10
 .type log10,@function
 log10:
+	ENDBRANCH32
 	fldlg2
 	fldl 4(%esp)
 	fyl2x
diff --git a/src/math/i386/log10f.s b/src/math/i386/log10f.s
index b055493a..70b0c447 100644
--- a/src/math/i386/log10f.s
+++ b/src/math/i386/log10f.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log10f
 .type log10f,@function
 log10f:
+	ENDBRANCH32
 	fldlg2
 	flds 4(%esp)
 	fyl2x
diff --git a/src/math/i386/log10l.s b/src/math/i386/log10l.s
index aaa44f2f..663227fd 100644
--- a/src/math/i386/log10l.s
+++ b/src/math/i386/log10l.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log10l
 .type log10l,@function
 log10l:
+	ENDBRANCH32
 	fldlg2
 	fldt 4(%esp)
 	fyl2x
diff --git a/src/math/i386/log1p.s b/src/math/i386/log1p.s
index f3c95f83..681bda68 100644
--- a/src/math/i386/log1p.s
+++ b/src/math/i386/log1p.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log1p
 .type log1p,@function
 log1p:
+	ENDBRANCH32
 	mov 8(%esp),%eax
 	fldln2
 	and $0x7fffffff,%eax
diff --git a/src/math/i386/log1pf.s b/src/math/i386/log1pf.s
index 9f13d95f..7bc9f87e 100644
--- a/src/math/i386/log1pf.s
+++ b/src/math/i386/log1pf.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log1pf
 .type log1pf,@function
 log1pf:
+	ENDBRANCH32
 	mov 4(%esp),%eax
 	fldln2
 	and $0x7fffffff,%eax
diff --git a/src/math/i386/log1pl.s b/src/math/i386/log1pl.s
index a048ab6b..5e549af6 100644
--- a/src/math/i386/log1pl.s
+++ b/src/math/i386/log1pl.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log1pl
 .type log1pl,@function
 log1pl:
+	ENDBRANCH32
 	mov 10(%esp),%eax
 	fldln2
 	and $0x7fffffff,%eax
diff --git a/src/math/i386/log2.s b/src/math/i386/log2.s
index 7eff0b61..c50525bd 100644
--- a/src/math/i386/log2.s
+++ b/src/math/i386/log2.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log2
 .type log2,@function
 log2:
+	ENDBRANCH32
 	fld1
 	fldl 4(%esp)
 	fyl2x
diff --git a/src/math/i386/log2f.s b/src/math/i386/log2f.s
index b32fa2f7..06cf0063 100644
--- a/src/math/i386/log2f.s
+++ b/src/math/i386/log2f.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log2f
 .type log2f,@function
 log2f:
+	ENDBRANCH32
 	fld1
 	flds 4(%esp)
 	fyl2x
diff --git a/src/math/i386/log2l.s b/src/math/i386/log2l.s
index c58f56fd..6d9d5217 100644
--- a/src/math/i386/log2l.s
+++ b/src/math/i386/log2l.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global log2l
 .type log2l,@function
 log2l:
+	ENDBRANCH32
 	fld1
 	fldt 4(%esp)
 	fyl2x
diff --git a/src/math/i386/logf.s b/src/math/i386/logf.s
index 4d0346a4..e846d3f6 100644
--- a/src/math/i386/logf.s
+++ b/src/math/i386/logf.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global logf
 .type logf,@function
 logf:
+	ENDBRANCH32
 	fldln2
 	flds 4(%esp)
 	fyl2x
diff --git a/src/math/i386/logl.s b/src/math/i386/logl.s
index d4e3339b..1cb52139 100644
--- a/src/math/i386/logl.s
+++ b/src/math/i386/logl.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global logl
 .type logl,@function
 logl:
+	ENDBRANCH32
 	fldln2
 	fldt 4(%esp)
 	fyl2x
diff --git a/src/math/i386/remquo.s b/src/math/i386/remquo.s
index 598e7549..6bb69298 100644
--- a/src/math/i386/remquo.s
+++ b/src/math/i386/remquo.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global remquof
 .type remquof,@function
 remquof:
+	ENDBRANCH32
 	mov 12(%esp),%ecx
 	flds 8(%esp)
 	flds 4(%esp)
@@ -11,6 +14,7 @@ remquof:
 .global remquol
 .type remquol,@function
 remquol:
+	ENDBRANCH32
 	mov 28(%esp),%ecx
 	fldt 16(%esp)
 	fldt 4(%esp)
@@ -21,6 +25,7 @@ remquol:
 .global remquo
 .type remquo,@function
 remquo:
+	ENDBRANCH32
 	mov 20(%esp),%ecx
 	fldl 12(%esp)
 	fldl 4(%esp)
diff --git a/src/math/i386/scalbn.s b/src/math/i386/scalbn.s
index 8bf302f2..188f2ede 100644
--- a/src/math/i386/scalbn.s
+++ b/src/math/i386/scalbn.s
@@ -1,16 +1,21 @@
+.include "ibt.s"
+
 .global ldexp
 .type ldexp,@function
 ldexp:
+	ENDBRANCH32
 	nop
 
 .global scalbln
 .type scalbln,@function
 scalbln:
+	ENDBRANCH32
 	nop
 
 .global scalbn
 .type scalbn,@function
 scalbn:
+	ENDBRANCH32
 	mov 12(%esp),%eax
 	add $0x3ffe,%eax
 	cmp $0x7ffd,%eax
diff --git a/src/math/i386/scalbnf.s b/src/math/i386/scalbnf.s
index 9cb9ef5f..5d23bbe1 100644
--- a/src/math/i386/scalbnf.s
+++ b/src/math/i386/scalbnf.s
@@ -1,16 +1,21 @@
+.include "ibt.s"
+
 .global ldexpf
 .type ldexpf,@function
 ldexpf:
+	ENDBRANCH32
 	nop
 
 .global scalblnf
 .type scalblnf,@function
 scalblnf:
+	ENDBRANCH32
 	nop
 
 .global scalbnf
 .type scalbnf,@function
 scalbnf:
+	ENDBRANCH32
 	mov 8(%esp),%eax
 	add $0x3fe,%eax
 	cmp $0x7fd,%eax
diff --git a/src/math/i386/scalbnl.s b/src/math/i386/scalbnl.s
index 54414c2e..5f1d78de 100644
--- a/src/math/i386/scalbnl.s
+++ b/src/math/i386/scalbnl.s
@@ -1,16 +1,21 @@
+.include "ibt.s"
+
 .global ldexpl
 .type ldexpl,@function
 ldexpl:
+	ENDBRANCH32
 	nop
 
 .global scalblnl
 .type scalblnl,@function
 scalblnl:
+	ENDBRANCH32
 	nop
 
 .global scalbnl
 .type scalbnl,@function
 scalbnl:
+	ENDBRANCH32
 	mov 16(%esp),%eax
 	add $0x3ffe,%eax
 	cmp $0x7ffd,%eax
diff --git a/src/process/i386/vfork.s b/src/process/i386/vfork.s
index 3d0e6d6b..a055623a 100644
--- a/src/process/i386/vfork.s
+++ b/src/process/i386/vfork.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global vfork
 .type vfork,@function
 vfork:
+	ENDBRANCH32
 	pop %edx
 	mov $190,%eax
 	int $128
diff --git a/src/setjmp/i386/longjmp.s b/src/setjmp/i386/longjmp.s
index 8188f06b..f0b54db4 100644
--- a/src/setjmp/i386/longjmp.s
+++ b/src/setjmp/i386/longjmp.s
@@ -1,9 +1,12 @@
+.include "ibt.s"
+
 .global _longjmp
 .global longjmp
 .type _longjmp,@function
 .type longjmp,@function
 _longjmp:
 longjmp:
+	ENDBRANCH32
 	mov  4(%esp),%edx
 	mov  8(%esp),%eax
 	cmp       $1,%eax
diff --git a/src/setjmp/i386/setjmp.s b/src/setjmp/i386/setjmp.s
index 4d19cf87..76cd58be 100644
--- a/src/setjmp/i386/setjmp.s
+++ b/src/setjmp/i386/setjmp.s
@@ -1,3 +1,5 @@
+.include "ibt.s"
+
 .global ___setjmp
 .hidden ___setjmp
 .global __setjmp
@@ -10,6 +12,7 @@ ___setjmp:
 __setjmp:
 _setjmp:
 setjmp:
+	ENDBRANCH32
 	mov 4(%esp), %eax
 	mov    %ebx, (%eax)
 	mov    %esi, 4(%eax)
diff --git a/src/signal/i386/restore.s b/src/signal/i386/restore.s
index ccc94307..6f668b9a 100644
--- a/src/signal/i386/restore.s
+++ b/src/signal/i386/restore.s
@@ -1,7 +1,10 @@
+.include "ibt.s"
+
 .global __restore
 .hidden __restore
 .type __restore,@function
 __restore:
+	ENDBRANCH32
 	popl %eax
 	movl $119, %eax
 	int $0x80
@@ -10,5 +13,6 @@ __restore:
 .hidden __restore_rt
 .type __restore_rt,@function
 __restore_rt:
+	ENDBRANCH32
 	movl $173, %eax
 	int $0x80
diff --git a/src/signal/i386/sigsetjmp.s b/src/signal/i386/sigsetjmp.s
index 690b251c..ed69432c 100644
--- a/src/signal/i386/sigsetjmp.s
+++ b/src/signal/i386/sigsetjmp.s
@@ -1,9 +1,12 @@
+.include "ibt.s"
+
 .global sigsetjmp
 .global __sigsetjmp
 .type sigsetjmp,@function
 .type __sigsetjmp,@function
 sigsetjmp:
 __sigsetjmp:
+	ENDBRANCH32
 	mov 8(%esp),%ecx
 	jecxz 1f
 
diff --git a/src/string/i386/memcpy.s b/src/string/i386/memcpy.s
index 0608dd83..9650d880 100644
--- a/src/string/i386/memcpy.s
+++ b/src/string/i386/memcpy.s
@@ -1,8 +1,11 @@
+.include "ibt.s"
+
 .global memcpy
 .global __memcpy_fwd
 .hidden __memcpy_fwd
 .type memcpy,@function
 memcpy:
+	ENDBRANCH32
 __memcpy_fwd:
 	push %esi
 	push %edi
diff --git a/src/string/i386/memmove.s b/src/string/i386/memmove.s
index 2a6a504b..36dfd2c9 100644
--- a/src/string/i386/memmove.s
+++ b/src/string/i386/memmove.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global memmove
 .type memmove,@function
 memmove:
+	ENDBRANCH32
 	mov 4(%esp),%eax
 	sub 8(%esp),%eax
 	cmp 12(%esp),%eax
diff --git a/src/string/i386/memset.s b/src/string/i386/memset.s
index d00422c4..3067fc63 100644
--- a/src/string/i386/memset.s
+++ b/src/string/i386/memset.s
@@ -1,6 +1,9 @@
+.include "ibt.s"
+
 .global memset
 .type memset,@function
 memset:
+	ENDBRANCH32
 	mov 12(%esp),%ecx
 	cmp $62,%ecx
 	ja 2f
@@ -47,7 +50,7 @@ memset:
 	mov %edx,(-1-2-4-8-8)(%eax,%ecx)
 	mov %edx,(-1-2-4-8-4)(%eax,%ecx)
 
-1:	ret 	
+1:	ret
 
 2:	movzbl 8(%esp),%eax
 	mov %edi,12(%esp)
@@ -63,7 +66,7 @@ memset:
 	mov 4(%esp),%eax
 	mov 12(%esp),%edi
 	ret
-	
+
 2:	xor %edx,%edx
 	sub %edi,%edx
 	and $15,%edx
diff --git a/src/thread/i386/__set_thread_area.s b/src/thread/i386/__set_thread_area.s
index aa6852be..5bddb956 100644
--- a/src/thread/i386/__set_thread_area.s
+++ b/src/thread/i386/__set_thread_area.s
@@ -1,8 +1,11 @@
+.include "ibt.s"
+
 .text
 .global __set_thread_area
 .hidden __set_thread_area
 .type   __set_thread_area,@function
 __set_thread_area:
+	ENDBRANCH32
 	push %ebx
 	push $0x51
 	push $0xfffff
diff --git a/src/thread/i386/__unmapself.s b/src/thread/i386/__unmapself.s
index d6569594..0b1feb2e 100644
--- a/src/thread/i386/__unmapself.s
+++ b/src/thread/i386/__unmapself.s
@@ -1,7 +1,10 @@
+.include "ibt.s"
+
 .text
 .global __unmapself
 .type   __unmapself,@function
 __unmapself:
+	ENDBRANCH32
 	movl $91,%eax
 	movl 4(%esp),%ebx
 	movl 8(%esp),%ecx
diff --git a/src/thread/i386/clone.s b/src/thread/i386/clone.s
index e237d3c6..79050643 100644
--- a/src/thread/i386/clone.s
+++ b/src/thread/i386/clone.s
@@ -1,8 +1,11 @@
+.include "ibt.s"
+
 .text
 .global __clone
 .hidden __clone
 .type   __clone,@function
 __clone:
+	ENDBRANCH32
 	push %ebp
 	mov %esp,%ebp
 	push %ebx
diff --git a/src/thread/i386/syscall_cp.s b/src/thread/i386/syscall_cp.s
index 7dce1eb3..7a5f0f98 100644
--- a/src/thread/i386/syscall_cp.s
+++ b/src/thread/i386/syscall_cp.s
@@ -1,3 +1,5 @@
+.include "ibt.s"
+
 .text
 .global __cp_begin
 .hidden __cp_begin
@@ -10,6 +12,7 @@
 .hidden __syscall_cp_asm
 .type   __syscall_cp_asm,@function
 __syscall_cp_asm:
+	ENDBRANCH32
 	mov 4(%esp),%ecx
 	pushl %ebx
 	pushl %esi
diff --git a/src/thread/i386/tls.s b/src/thread/i386/tls.s
index 6e4c4cb9..fdd2278a 100644
--- a/src/thread/i386/tls.s
+++ b/src/thread/i386/tls.s
@@ -1,7 +1,10 @@
+.include "ibt.s"
+
 .text
 .global ___tls_get_addr
 .type ___tls_get_addr,@function
 ___tls_get_addr:
+	ENDBRANCH32
 	mov %gs:4,%edx
 	mov (%eax),%ecx
 	mov 4(%eax),%eax
-- 
2.27.0


      parent reply	other threads:[~2020-10-19 22:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 22:43 [musl] [PATCH 0/4] Add CET IBT Support to MUSL Joao Moreira
2020-10-19 22:43 ` [musl] [PATCH 1/4] Support ASFLAGS in configure and Makefile Joao Moreira
2020-10-19 22:43 ` [musl] [PATCH 2/4] Add ENDBRANCH64 and ENDBRANCH32 macro definitions Joao Moreira
2020-10-19 22:43 ` [musl] [PATCH 3/4] Add endbr64 to x86_64 assembly functions Joao Moreira
2020-10-19 22:43 ` Joao Moreira [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201019224342.53303-5-joao.moreira@intel.com \
    --to=joao.moreira@intel.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).