diff -Nurp binutils-2.23.51.0.8/ld/emultempl/elf32.em binutils-2.23.51.0.8-relro/ld/emultempl/elf32.em --- binutils-2.23.51.0.8/ld/emultempl/elf32.em 2012-12-21 21:40:41.000000000 +0200 +++ binutils-2.23.51.0.8-relro/ld/emultempl/elf32.em 2012-12-29 16:19:21.700622109 +0200 @@ -107,6 +107,7 @@ gld${EMULATION_NAME}_before_parse (void) config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`; link_info.sharable_sections = `if test "$SHARABLE_SECTIONS" = "yes" ; then echo TRUE ; else echo FALSE ; fi`; + link_info.relro = TRUE; } EOF diff -Nurp binutils-2.23.51.0.8/ld/testsuite/config/default.exp binutils-2.23.51.0.8-relro/ld/testsuite/config/default.exp --- binutils-2.23.51.0.8/ld/testsuite/config/default.exp 2012-12-21 21:40:41.000000000 +0200 +++ binutils-2.23.51.0.8-relro/ld/testsuite/config/default.exp 2012-12-29 16:19:21.698621956 +0200 @@ -23,7 +23,7 @@ # if ![info exists ld] then { - set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] + set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro" } if ![info exists as] then { @@ -69,7 +69,7 @@ if {![file isdirectory tmpdir/ld]} then catch "exec ln -s ../../ld-new tmpdir/ld/ld" status catch "exec ln -s ld tmpdir/ld/collect-ld" status } -set gcc_ld_flag "-B[pwd]/tmpdir/ld/" +set gcc_ld_flag "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro" # load the linker path if {[file exists tmpdir/libpath.exp]} { @@ -279,7 +279,7 @@ if ![info exists READELFFLAGS] then { } if ![info exists LD] then { - set LD [findfile $base_dir/ld-new ./ld-new [transform ld]] + set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro" } if ![info exists LDFLAGS] then { diff -Nurp binutils-2.23.51.0.8/ld/testsuite/ld-bootstrap/bootstrap.exp binutils-2.23.51.0.8-relro/ld/testsuite/ld-bootstrap/bootstrap.exp --- binutils-2.23.51.0.8/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-12-21 21:40:41.000000000 +0200 +++ binutils-2.23.51.0.8-relro/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-12-29 16:19:21.699622030 +0200 @@ -71,7 +71,13 @@ foreach flags {"" "strip" "--static" "-- # This test can only be run if we have the ld build directory, # since we need the object files. - if {$ld != "$objdir/ld-new"} { + set ldexe $ld + set ldparm [string first " " $ld] + if { $ldparm > 0 } then { + set ldparm [expr $ldparm - 1] + set ldexe [string range $ld 0 $ldparm] + } + if {$ldexe != "$objdir/ld-new"} { untested $testname continue }