Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Turn on -z separate-code for x86, like linux has done. This ...



details:   https://anonhg.NetBSD.org/src/rev/8a98fcf08b58
branches:  trunk
changeset: 372936:8a98fcf08b58
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 06 15:47:38 2023 +0000

description:
Turn on -z separate-code for x86, like linux has done. This splits the text
and data segment load sections into two pieces, for at total of 4 PT_LOAD
sections: two for text (r--, r-x) and two for data (r--, rw-). For x86_64
this changes the default max page size from 2M to 4K.

diffstat:

 distrib/sets/lists/comp/md.amd64                       |  6 +++++-
 external/gpl3/binutils/dist/bfd/configure              |  4 ++--
 external/gpl3/binutils/dist/bfd/configure.ac           |  4 ++--
 external/gpl3/binutils/dist/ld/configure.tgt           |  2 +-
 external/gpl3/binutils/lib/libbfd/arch/i386/config.h   |  2 +-
 external/gpl3/binutils/lib/libbfd/arch/i386/defs.mk    |  6 +++---
 external/gpl3/binutils/lib/libbfd/arch/x86_64/config.h |  4 ++--
 external/gpl3/binutils/usr.bin/ld/Makefile             |  9 ++++++++-
 external/gpl3/binutils/usr.bin/ld/arch/i386/config.h   |  6 +++---
 external/gpl3/binutils/usr.bin/ld/arch/x86_64/config.h |  4 ++--
 10 files changed, 29 insertions(+), 18 deletions(-)

diffs (198 lines):

diff -r 0490e687b5d6 -r 8a98fcf08b58 distrib/sets/lists/comp/md.amd64
--- a/distrib/sets/lists/comp/md.amd64  Fri Jan 06 15:35:05 2023 +0000
+++ b/distrib/sets/lists/comp/md.amd64  Fri Jan 06 15:47:38 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.291 2022/12/28 22:04:05 christos Exp $
+# $NetBSD: md.amd64,v 1.292 2023/01/06 15:47:38 christos Exp $
 ./usr/include/amd64                            comp-c-include
 ./usr/include/amd64/ansi.h                     comp-c-include
 ./usr/include/amd64/aout_machdep.h             comp-c-include
@@ -1437,6 +1437,7 @@
 ./usr/libdata/ldscripts/elf_i386.x             comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_i386.xbn           comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_i386.xc            comp-util-bin           binutils
+./usr/libdata/ldscripts/elf_i386.xce           comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_i386.xd            comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_i386.xdc           comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_i386.xdw           comp-util-bin           binutils
@@ -1450,6 +1451,7 @@
 ./usr/libdata/ldscripts/elf_iamcu.x            comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_iamcu.xbn          comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_iamcu.xc           comp-util-bin           binutils
+./usr/libdata/ldscripts/elf_iamcu.xce          comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_iamcu.xd           comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_iamcu.xdc          comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_iamcu.xdw          comp-util-bin           binutils
@@ -1463,6 +1465,7 @@
 ./usr/libdata/ldscripts/elf_k1om.x             comp-util-bin           binutils=234
 ./usr/libdata/ldscripts/elf_k1om.xbn           comp-util-bin           binutils=234
 ./usr/libdata/ldscripts/elf_k1om.xc            comp-util-bin           binutils=234
+./usr/libdata/ldscripts/elf_k1om.xc            comp-util-bin           binutils=234
 ./usr/libdata/ldscripts/elf_k1om.xd            comp-util-bin           binutils=234
 ./usr/libdata/ldscripts/elf_k1om.xdc           comp-util-bin           binutils=234
 ./usr/libdata/ldscripts/elf_k1om.xdw           comp-util-bin           binutils=234
@@ -1489,6 +1492,7 @@
 ./usr/libdata/ldscripts/elf_x86_64.x           comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_x86_64.xbn         comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_x86_64.xc          comp-util-bin           binutils
+./usr/libdata/ldscripts/elf_x86_64.xce         comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_x86_64.xd          comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_x86_64.xdc         comp-util-bin           binutils
 ./usr/libdata/ldscripts/elf_x86_64.xdw         comp-util-bin           binutils
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/dist/bfd/configure
--- a/external/gpl3/binutils/dist/bfd/configure Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/dist/bfd/configure Fri Jan 06 15:47:38 2023 +0000
@@ -11977,9 +11977,9 @@
 esac
 fi
 
-# Enable -z separate-code by default for Linux/x86.
+# Enable -z separate-code by default for Linux/x86 and NetBSD/x86
 case "${target}" in
-i[3-7]86-*-linux-* | x86_64-*-linux-*)
+i[3-7]86-*-linux-* | x86_64-*-linux-* | i[3-7]86-*-netbsd* | x86_64-*-netbsd*)
   if test ${ac_default_ld_z_separate_code} = unset; then
     ac_default_ld_z_separate_code=1
   fi
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/dist/bfd/configure.ac
--- a/external/gpl3/binutils/dist/bfd/configure.ac      Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/dist/bfd/configure.ac      Fri Jan 06 15:47:38 2023 +0000
@@ -136,10 +136,10 @@
   yes) ac_default_ld_z_separate_code=1 ;;
   no) ac_default_ld_z_separate_code=0 ;;
 esac])
-# Enable -z separate-code by default for Linux/x86.
+# Enable -z separate-code by default for Linux/x86 and NetBSD/x86
 changequote(,)dnl
 case "${target}" in
-i[3-7]86-*-linux-* | x86_64-*-linux-*)
+i[3-7]86-*-linux-* | x86_64-*-linux-* | i[3-7]86-*-netbsd | x86_64-*-netbsd* )
 changequote([,])dnl
   if test ${ac_default_ld_z_separate_code} = unset; then
     ac_default_ld_z_separate_code=1
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/dist/ld/configure.tgt
--- a/external/gpl3/binutils/dist/ld/configure.tgt      Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/dist/ld/configure.tgt      Fri Jan 06 15:47:38 2023 +0000
@@ -1219,7 +1219,7 @@
 
 # Enable -z separate-code and --warn-textrel by default for Linux/x86.
 case "${target}" in
-i[3-7]86-*-linux-* | x86_64-*-linux-*)
+i[3-7]86-*-linux-* | x86_64-*-linux-* | i[3-7]86-*-netbsd* | x86_64-*-netbsd*)
   if test ${ac_default_ld_z_separate_code} = unset; then
     ac_default_ld_z_separate_code=1
   fi
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/lib/libbfd/arch/i386/config.h
--- a/external/gpl3/binutils/lib/libbfd/arch/i386/config.h      Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/lib/libbfd/arch/i386/config.h      Fri Jan 06 15:47:38 2023 +0000
@@ -17,7 +17,7 @@
 
 /* Define to 1 if you want to enable -z separate-code in ELF linker by
    default. */
-#define DEFAULT_LD_Z_SEPARATE_CODE 0
+#define DEFAULT_LD_Z_SEPARATE_CODE 1
 
 /* Define if you want run-time sanity checks. */
 /* #undef ENABLE_CHECKING */
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/lib/libbfd/arch/i386/defs.mk
--- a/external/gpl3/binutils/lib/libbfd/arch/i386/defs.mk       Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/lib/libbfd/arch/i386/defs.mk       Fri Jan 06 15:47:38 2023 +0000
@@ -2,9 +2,9 @@
 # Generated from: NetBSD: mknative-binutils,v 1.14 2022/12/24 20:17:46 christos Exp 
 # Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp 
 #
-G_libbfd_la_DEPENDENCIES=elf32-i386.lo elfxx-x86.lo elf-ifunc.lo elf-vxworks.lo elf32.lo elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo dwarf2.lo elf32-gen.lo plugin.lo 
cpu-i386.lo cpu-iamcu.lo netbsd-core.lo ofiles
+G_libbfd_la_DEPENDENCIES=elf32-i386.lo elfxx-x86.lo elf-ifunc.lo elf-vxworks.lo elf32.lo elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo dwarf2.lo coff-i386.lo cofflink.lo 
coffgen.lo pei-i386.lo peigen.lo elf32-gen.lo plugin.lo cpu-i386.lo cpu-iamcu.lo netbsd-core.lo ofiles
 G_libbfd_la_OBJECTS=archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo  cache.lo coff-bfd.lo compress.lo corefile.lo elf-properties.lo  format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo  
opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo  syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo  verilog.lo
 G_DEFS=-DHAVE_CONFIG_H
 G_INCLUDES=
-G_TDEFAULTS=-DDEFAULT_VECTOR=i386_elf32_vec -DSELECT_VECS='&i386_elf32_vec,&iamcu_elf32_vec,&elf32_le_vec,&elf32_be_vec' -DSELECT_ARCHITECTURES='&bfd_i386_arch,&bfd_iamcu_arch'
-G_HAVEVECS=-DHAVE_i386_elf32_vec -DHAVE_iamcu_elf32_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec
+G_TDEFAULTS=-DDEFAULT_VECTOR=i386_elf32_vec -DSELECT_VECS='&i386_elf32_vec,&iamcu_elf32_vec,&i386_coff_vec,&i386_pei_vec,&elf32_le_vec,&elf32_be_vec' 
-DSELECT_ARCHITECTURES='&bfd_i386_arch,&bfd_iamcu_arch'
+G_HAVEVECS=-DHAVE_i386_elf32_vec -DHAVE_iamcu_elf32_vec -DHAVE_i386_coff_vec -DHAVE_i386_pei_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/lib/libbfd/arch/x86_64/config.h
--- a/external/gpl3/binutils/lib/libbfd/arch/x86_64/config.h    Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/lib/libbfd/arch/x86_64/config.h    Fri Jan 06 15:47:38 2023 +0000
@@ -1,5 +1,5 @@
 /* This file is automatically generated.  DO NOT EDIT! */
-/* Generated from: NetBSD: mknative-binutils,v 1.13 2020/04/04 01:34:53 christos Exp  */
+/* Generated from: NetBSD: mknative-binutils,v 1.14 2022/12/24 20:17:46 christos Exp  */
 /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
 
 /* config.h.  Generated from config.in by configure.  */
@@ -17,7 +17,7 @@
 
 /* Define to 1 if you want to enable -z separate-code in ELF linker by
    default. */
-#define DEFAULT_LD_Z_SEPARATE_CODE 0
+#define DEFAULT_LD_Z_SEPARATE_CODE 1
 
 /* Define if you want run-time sanity checks. */
 /* #undef ENABLE_CHECKING */
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/usr.bin/ld/Makefile
--- a/external/gpl3/binutils/usr.bin/ld/Makefile        Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/usr.bin/ld/Makefile        Fri Jan 06 15:47:38 2023 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.35 2022/12/24 20:17:10 christos Exp $
+#      $NetBSD: Makefile,v 1.36 2023/01/06 15:47:38 christos Exp $
 
 CPPFLAGS+=     -I${.CURDIR}/arch/${BINUTILS_MACHINE_ARCH} \
                -I${DIST}/ld \
@@ -87,6 +87,13 @@
 .   endif
 .  endfor
 . endif
+. if ${BINUTILS_MACHINE_ARCH} == "x86_64" || ${BINUTILS_MACHINE_ARCH} == "i386"
+.  for e in xce
+.   if exists(ldscripts/${f}.${e})
+FILES+= ${f}.${e}
+.   endif
+.  endfor
+. endif
 .endfor
 
 .include <bsd.prog.mk>
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/usr.bin/ld/arch/i386/config.h
--- a/external/gpl3/binutils/usr.bin/ld/arch/i386/config.h      Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/usr.bin/ld/arch/i386/config.h      Fri Jan 06 15:47:38 2023 +0000
@@ -26,10 +26,10 @@
 #define DEFAULT_LD_EXECSTACK 1
 
 /* The default method for DT_TEXTREL check in ELF linker. */
-#define DEFAULT_LD_TEXTREL_CHECK textrel_check_none
+#define DEFAULT_LD_TEXTREL_CHECK textrel_check_warning
 
 /* Define to 1 if DT_TEXTREL check is warning in ELF linker by default. */
-#define DEFAULT_LD_TEXTREL_CHECK_WARNING 0
+#define DEFAULT_LD_TEXTREL_CHECK_WARNING 1
 
 /* Define to 1 if you want to enable --warn-execstack in ELF linker by
    default. */
@@ -44,7 +44,7 @@
 
 /* Define to 1 if you want to enable -z separate-code in ELF linker by
    default. */
-#define DEFAULT_LD_Z_SEPARATE_CODE 0
+#define DEFAULT_LD_Z_SEPARATE_CODE 1
 
 /* Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default.
    */
diff -r 0490e687b5d6 -r 8a98fcf08b58 external/gpl3/binutils/usr.bin/ld/arch/x86_64/config.h
--- a/external/gpl3/binutils/usr.bin/ld/arch/x86_64/config.h    Fri Jan 06 15:35:05 2023 +0000
+++ b/external/gpl3/binutils/usr.bin/ld/arch/x86_64/config.h    Fri Jan 06 15:47:38 2023 +0000
@@ -1,5 +1,5 @@
 /* This file is automatically generated.  DO NOT EDIT! */
-/* Generated from: NetBSD: mknative-binutils,v 1.13 2020/04/04 01:34:53 christos Exp  */
+/* Generated from: NetBSD: mknative-binutils,v 1.14 2022/12/24 20:17:46 christos Exp  */
 /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
 
 /* config.h.  Generated from config.in by configure.  */
@@ -44,7 +44,7 @@
 
 /* Define to 1 if you want to enable -z separate-code in ELF linker by
    default. */
-#define DEFAULT_LD_Z_SEPARATE_CODE 0
+#define DEFAULT_LD_Z_SEPARATE_CODE 1
 
 /* Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default.
    */



Home | Main Index | Thread Index | Old Index