diff mbox series

[1/4] x86: Move x86-64 shadow stack startup codes

Message ID 20240109193041.3987157-2-hjl.tools@gmail.com
State New
Headers show
Series i386: Remove remaining CET bits | expand

Commit Message

H.J. Lu Jan. 9, 2024, 7:30 p.m. UTC
Add sysdeps/i386/libc-start.h and move x86-64 shadow stack startup codes
to sysdeps/x86_64/libc-start.h
---
 sysdeps/i386/libc-start.h            | 25 +++++++++++++++++++++++++
 sysdeps/{x86 => x86_64}/libc-start.h |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/i386/libc-start.h
 rename sysdeps/{x86 => x86_64}/libc-start.h (98%)

Comments

Adhemerval Zanella Netto Jan. 9, 2024, 7:51 p.m. UTC | #1
On 09/01/24 16:30, H.J. Lu wrote:
> Add sysdeps/i386/libc-start.h and move x86-64 shadow stack startup codes
> to sysdeps/x86_64/libc-start.h
> ---
>  sysdeps/i386/libc-start.h            | 25 +++++++++++++++++++++++++
>  sysdeps/{x86 => x86_64}/libc-start.h |  2 +-
>  2 files changed, 26 insertions(+), 1 deletion(-)
>  create mode 100644 sysdeps/i386/libc-start.h
>  rename sysdeps/{x86 => x86_64}/libc-start.h (98%)
> 
> diff --git a/sysdeps/i386/libc-start.h b/sysdeps/i386/libc-start.h
> new file mode 100644
> index 0000000000..c9b7d3614e
> --- /dev/null
> +++ b/sysdeps/i386/libc-start.h
> @@ -0,0 +1,25 @@
> +/* i386 definitions for libc main startup.
> +   Copyright (C) 2018-2024 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef SHARED
> +# define ARCH_SETUP_IREL() apply_irel ()
> +# define ARCH_APPLY_IREL()
> +# ifndef ARCH_SETUP_TLS
> +#  define ARCH_SETUP_TLS() __libc_setup_tls ()
> +# endif
> +#endif /* !SHARED */

I think you can just omit this file and use the generic one instead
(sysdeps/generic/libc-start.h).

> diff --git a/sysdeps/x86/libc-start.h b/sysdeps/x86_64/libc-start.h
> similarity index 98%
> rename from sysdeps/x86/libc-start.h
> rename to sysdeps/x86_64/libc-start.h
> index c3cc05888d..63fef17029 100644
> --- a/sysdeps/x86/libc-start.h
> +++ b/sysdeps/x86_64/libc-start.h
> @@ -1,4 +1,4 @@
> -/* X86 definitions for libc main startup.
> +/* x86-64 definitions for libc main startup.
>     Copyright (C) 2018-2024 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  

Ok.
H.J. Lu Jan. 9, 2024, 8:07 p.m. UTC | #2
On Tue, Jan 9, 2024 at 11:51 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 09/01/24 16:30, H.J. Lu wrote:
> > Add sysdeps/i386/libc-start.h and move x86-64 shadow stack startup codes
> > to sysdeps/x86_64/libc-start.h
> > ---
> >  sysdeps/i386/libc-start.h            | 25 +++++++++++++++++++++++++
> >  sysdeps/{x86 => x86_64}/libc-start.h |  2 +-
> >  2 files changed, 26 insertions(+), 1 deletion(-)
> >  create mode 100644 sysdeps/i386/libc-start.h
> >  rename sysdeps/{x86 => x86_64}/libc-start.h (98%)
> >
> > diff --git a/sysdeps/i386/libc-start.h b/sysdeps/i386/libc-start.h
> > new file mode 100644
> > index 0000000000..c9b7d3614e
> > --- /dev/null
> > +++ b/sysdeps/i386/libc-start.h
> > @@ -0,0 +1,25 @@
> > +/* i386 definitions for libc main startup.
> > +   Copyright (C) 2018-2024 Free Software Foundation, Inc.
> > +   This file is part of the GNU C Library.
> > +
> > +   The GNU C Library is free software; you can redistribute it and/or
> > +   modify it under the terms of the GNU Lesser General Public
> > +   License as published by the Free Software Foundation; either
> > +   version 2.1 of the License, or (at your option) any later version.
> > +
> > +   The GNU C Library is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +   Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > +   License along with the GNU C Library; if not, see
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef SHARED
> > +# define ARCH_SETUP_IREL() apply_irel ()
> > +# define ARCH_APPLY_IREL()
> > +# ifndef ARCH_SETUP_TLS
> > +#  define ARCH_SETUP_TLS() __libc_setup_tls ()
> > +# endif
> > +#endif /* !SHARED */
>
> I think you can just omit this file and use the generic one instead
> (sysdeps/generic/libc-start.h).

I sent out the v2 patches.  Changes in v2:

1. Remove sysdeps/i386/libc-start.h.
2. Replace x86 to x86-64 in comments in sysdeps/x86_64/dl-cet.c and
sysdeps/x86_64/feature-control.h.
3. Replace _CET_CONTROL_H with _X86_64_FEATURE_CONTROL_H in
sysdeps/x86_64/feature-control.h.

> > diff --git a/sysdeps/x86/libc-start.h b/sysdeps/x86_64/libc-start.h
> > similarity index 98%
> > rename from sysdeps/x86/libc-start.h
> > rename to sysdeps/x86_64/libc-start.h
> > index c3cc05888d..63fef17029 100644
> > --- a/sysdeps/x86/libc-start.h
> > +++ b/sysdeps/x86_64/libc-start.h
> > @@ -1,4 +1,4 @@
> > -/* X86 definitions for libc main startup.
> > +/* x86-64 definitions for libc main startup.
> >     Copyright (C) 2018-2024 Free Software Foundation, Inc.
> >     This file is part of the GNU C Library.
> >
>
> Ok.
diff mbox series

Patch

diff --git a/sysdeps/i386/libc-start.h b/sysdeps/i386/libc-start.h
new file mode 100644
index 0000000000..c9b7d3614e
--- /dev/null
+++ b/sysdeps/i386/libc-start.h
@@ -0,0 +1,25 @@ 
+/* i386 definitions for libc main startup.
+   Copyright (C) 2018-2024 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef SHARED
+# define ARCH_SETUP_IREL() apply_irel ()
+# define ARCH_APPLY_IREL()
+# ifndef ARCH_SETUP_TLS
+#  define ARCH_SETUP_TLS() __libc_setup_tls ()
+# endif
+#endif /* !SHARED */
diff --git a/sysdeps/x86/libc-start.h b/sysdeps/x86_64/libc-start.h
similarity index 98%
rename from sysdeps/x86/libc-start.h
rename to sysdeps/x86_64/libc-start.h
index c3cc05888d..63fef17029 100644
--- a/sysdeps/x86/libc-start.h
+++ b/sysdeps/x86_64/libc-start.h
@@ -1,4 +1,4 @@ 
-/* X86 definitions for libc main startup.
+/* x86-64 definitions for libc main startup.
    Copyright (C) 2018-2024 Free Software Foundation, Inc.
    This file is part of the GNU C Library.