# DP: Turn on -Wl,-z,relro by default.

---
 gcc/doc/invoke.texi |    3 +++
 gcc/gcc.c           |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

--- a/src/gcc/doc/invoke.texi
+++ b/src/gcc/doc/invoke.texi
@@ -13520,6 +13520,9 @@ For example, @option{-Wl,-Map,output.map
 linker.  When using the GNU linker, you can also get the same effect with
 @option{-Wl,-Map=output.map}.
 
+NOTE: In Ubuntu 8.10 and later versions, for LDFLAGS, the option
+@option{-Wl,-z,relro} is used.  To disable, use @option{-Wl,-z,norelro}.
+
 @item -u @var{symbol}
 @opindex u
 Pretend the symbol @var{symbol} is undefined, to force linking of
--- a/src/gcc/gcc.c
+++ b/src/gcc/gcc.c
@@ -1122,6 +1122,12 @@ proper position among the other output f
    to understand them.  In practice, this means it had better be collect2.  */
 /* %{e*} includes -export-dynamic; see comment in common.opt.  */
 
+#if defined(ACCEL_COMPILER)
+# define RELRO_SPEC ""
+#else
+# define RELRO_SPEC "-z relro "
+#endif
+
 #ifndef LINK_COMMAND_SPEC
 #define LINK_COMMAND_SPEC "\
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
@@ -1130,6 +1136,7 @@ proper position among the other output f
    "%{flto|flto=*:%<fcompare-debug*} \
     %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
    "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
+   RELRO_SPEC \
    "%X %{o*} %{e*} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
     %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \
