> Date: Sat, 6 Aug 2016 20:34:07 -0700
> From: Philip Guenther <[email protected]>
> 
> We have kbind(2), so we can do RELRO process *ALWAYS*, and not just when 
> -znow is used to perform all relocations at load-time.
> 
> So, teach ld to just test for -zrelro.
> 
> ok?

ok kettenis@

> Index: gnu/usr.bin/binutils-2.17/ld/genscripts.sh
> ===================================================================
> RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/ld/genscripts.sh,v
> retrieving revision 1.2
> diff -u -p -r1.2 genscripts.sh
> --- gnu/usr.bin/binutils-2.17/ld/genscripts.sh        24 Apr 2011 20:19:25 
> -0000      1.2
> +++ gnu/usr.bin/binutils-2.17/ld/genscripts.sh        7 Aug 2016 03:18:36 
> -0000
> @@ -278,7 +278,7 @@ if test -n "$GENERATE_COMBRELOC_SCRIPT";
>    LD_FLAG=w
>    RELRO_NOW=" "
>    COMBRELOC=ldscripts/${EMULATION_NAME}.xw.tmp
> -  ( echo "/* Script for -z combreloc -z now -z relro: combine and sort reloc 
> sections */"
> +  ( echo "/* Script for -z combreloc -z relro: combine and sort reloc 
> sections */"
>      . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME}
>      . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
>    ) | sed -e '/^ *$/d;s/[    ]*$//' > ldscripts/${EMULATION_NAME}.xw
> @@ -309,7 +309,7 @@ if test -n "$GENERATE_SHLIB_SCRIPT"; the
>      LD_FLAG=wshared
>      RELRO_NOW=" "
>      COMBRELOC=ldscripts/${EMULATION_NAME}.xsw.tmp
> -    ( echo "/* Script for --shared -z combreloc -z now -z relro: shared 
> library, combine & sort relocs */"
> +    ( echo "/* Script for --shared -z combreloc -z relro: shared library, 
> combine & sort relocs */"
>        . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME}
>        . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
>      ) | sed -e '/^ *$/d;s/[  ]*$//' > ldscripts/${EMULATION_NAME}.xsw
> @@ -342,7 +342,7 @@ if test -n "$GENERATE_PIE_SCRIPT"; then
>      LD_FLAG=wpie
>      RELRO_NOW=" "
>      COMBRELOC=ldscripts/${EMULATION_NAME}.xdw.tmp
> -    ( echo "/* Script for -pie -z combreloc -z now -z relro: position 
> independent executable, combine & sort relocs */"
> +    ( echo "/* Script for -pie -z combreloc -z relro: position independent 
> executable, combine & sort relocs */"
>        . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME}
>        . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
>      ) | sed -e '/^ *$/d;s/[  ]*$//' > ldscripts/${EMULATION_NAME}.xdw
> Index: gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em
> ===================================================================
> RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em,v
> retrieving revision 1.7
> diff -u -p -r1.7 elf32.em
> --- gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em   21 Jun 2016 02:55:57 
> -0000      1.7
> +++ gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em   7 Aug 2016 03:18:38 
> -0000
> @@ -1940,8 +1940,7 @@ fi
>  if test -n "$GENERATE_PIE_SCRIPT" ; then
>  if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
>  echo '  ; else if (link_info.pie && link_info.combreloc' >> 
> e${EMULATION_NAME}.c
> -echo '             && link_info.relro' >> e${EMULATION_NAME}.c
> -echo '             && (link_info.flags & DF_BIND_NOW)) return' >> 
> e${EMULATION_NAME}.c
> +echo '             && link_info.relro) return' >> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xdw                      >> 
> e${EMULATION_NAME}.c
>  echo '  ; else if (link_info.pie && link_info.combreloc && 
> config.data_bss_contig == TRUE) return' >> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xdcz                >> 
> e${EMULATION_NAME}.c
> @@ -1956,8 +1955,7 @@ fi
>  if test -n "$GENERATE_SHLIB_SCRIPT" ; then
>  if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
>  echo '  ; else if (link_info.shared && link_info.combreloc' >> 
> e${EMULATION_NAME}.c
> -echo '             && link_info.relro' >> e${EMULATION_NAME}.c
> -echo '             && (link_info.flags & DF_BIND_NOW)) return' >> 
> e${EMULATION_NAME}.c
> +echo '             && link_info.relro) return' >> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xsw                      >> 
> e${EMULATION_NAME}.c
>  echo '  ; else if (link_info.shared && link_info.combreloc) return' >> 
> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xsc                      >> 
> e${EMULATION_NAME}.c
> @@ -1968,8 +1966,7 @@ fi
>  echo '  ; else if (config.data_bss_contig == TRUE) return' >> 
> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xz                 >> 
> e${EMULATION_NAME}.c
>  if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
> -echo '  ; else if (link_info.combreloc && link_info.relro' >> 
> e${EMULATION_NAME}.c
> -echo '             && (link_info.flags & DF_BIND_NOW)) return' >> 
> e${EMULATION_NAME}.c
> +echo '  ; else if (link_info.combreloc && link_info.relro) return' >> 
> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xw                       >> 
> e${EMULATION_NAME}.c
>  echo '  ; else if (link_info.combreloc) return'              >> 
> e${EMULATION_NAME}.c
>  sed $sc ldscripts/${EMULATION_NAME}.xc                       >> 
> e${EMULATION_NAME}.c
> @@ -2002,8 +1999,7 @@ fi
>  if test -n "$GENERATE_PIE_SCRIPT" ; then
>  if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
>  cat >>e${EMULATION_NAME}.c <<EOF
> -  else if (link_info.pie && link_info.combreloc
> -        && link_info.relro && (link_info.flags & DF_BIND_NOW))
> +  else if (link_info.pie && link_info.combreloc && link_info.relro)
>      return "ldscripts/${EMULATION_NAME}.xdw";
>    else if (link_info.pie && link_info.combreloc && config.data_bss_contig == 
> TRUE)
>      return "ldscripts/${EMULATION_NAME}.xdcz";
> @@ -2021,8 +2017,7 @@ fi
>  if test -n "$GENERATE_SHLIB_SCRIPT" ; then
>  if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
>  cat >>e${EMULATION_NAME}.c <<EOF
> -  else if (link_info.shared && link_info.combreloc
> -        && link_info.relro && (link_info.flags & DF_BIND_NOW))
> +  else if (link_info.shared && link_info.combreloc && link_info.relro)
>      return "ldscripts/${EMULATION_NAME}.xsw";
>    else if (link_info.shared && link_info.combreloc)
>      return "ldscripts/${EMULATION_NAME}.xsc";
> @@ -2039,8 +2034,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
>  EOF
>  if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
>  cat >>e${EMULATION_NAME}.c <<EOF
> -  else if (link_info.combreloc && link_info.relro
> -        && (link_info.flags & DF_BIND_NOW))
> +  else if (link_info.combreloc && link_info.relro)
>      return "ldscripts/${EMULATION_NAME}.xw";
>    else if (link_info.combreloc)
>      return "ldscripts/${EMULATION_NAME}.xc";
> 
> 

Reply via email to