+2015-02-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/17935
+       * elf32-i386.c (elf_i386_readonly_dynrelocs): Also issue a
+       warning for relocation in readonly section for -z text.
+       (elf_i386_size_dynamic_sections): Likewise.
+       * elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
+       (elf_x86_64_size_dynamic_sections): Likewise.
+
 2015-02-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/12365
 
 
          info->flags |= DF_TEXTREL;
 
-         if (info->warn_shared_textrel && info->shared)
-           info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
+         if ((info->warn_shared_textrel && info->shared)
+             || info->error_textrel)
+           info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"),
                                    p->sec->owner, h->root.root.string,
                                    p->sec);
 
                      && (info->flags & DF_TEXTREL) == 0)
                    {
                      info->flags |= DF_TEXTREL;
-                     if (info->warn_shared_textrel && info->shared)
-                       info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'.\n"),
+                     if ((info->warn_shared_textrel && info->shared)
+                         || info->error_textrel)
+                       info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'\n"),
                                                p->sec->owner, p->sec);
                    }
                }
 
 
          info->flags |= DF_TEXTREL;
 
-         if (info->warn_shared_textrel && info->shared)
-           info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
+         if ((info->warn_shared_textrel && info->shared)
+             || info->error_textrel)
+           info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"),
                                    p->sec->owner, h->root.root.string,
                                    p->sec);
 
                      && (info->flags & DF_TEXTREL) == 0)
                    {
                      info->flags |= DF_TEXTREL;
-                     if (info->warn_shared_textrel && info->shared)
-                       info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'.\n"),
+                     if ((info->warn_shared_textrel && info->shared)
+                         || info->error_textrel)
+                       info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'\n"),
                                                p->sec->owner, p->sec);
                    }
                }
 
+2015-02-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/17935
+       * ld-i386/i386.exp: Run pr17935-1 and pr17935-2.
+       * ld-x86-64/x86-64.exp: Likewise.
+
+       * ld-i386/pr17935-1.d: New file.
+       * ld-i386/pr17935-1.s: Likewise.
+       * ld-i386/pr17935-2.d: Likewise.
+       * ld-i386/pr17935-2.s: Likewise.
+       * ld-x86-64/pr17935-1.d: Likewise.
+       * ld-x86-64/pr17935-1.s: Likewise.
+       * ld-x86-64/pr17935-2.d: Likewise.
+       * ld-x86-64/pr17935-2.s: Likewise.
+
 2015-02-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/12365
 
 run_dump_test "pr13302"
 run_dump_test "pr14215"
 run_dump_test "pr17057"
+run_dump_test "pr17935-1"
+run_dump_test "pr17935-2"
 
 # Must be Linux native with the C compiler
 if { [isnative]
 
--- /dev/null
+# as: --32
+# ld: -m elf_i386 -shared -z text
+# error: warning: relocation against `foo' in readonly section `.text'
 
--- /dev/null
+       .text
+       .globl foo
+foo:
+       .byte 0
+       .globl  bar
+bar:
+       .dc.a   foo
 
--- /dev/null
+# as: --32
+# ld: -m elf_i386 -shared -z text
+# error: warning: relocation in readonly section `.text'
 
--- /dev/null
+       .text
+foo:
+       .byte 0
+       .globl  bar
+bar:
+       .dc.a   foo
 
--- /dev/null
+# as: --64
+# ld: -m elf_x86_64 -shared -z text
+# error: warning: relocation against `foo' in readonly section `.text'
 
--- /dev/null
+       .text
+       .globl foo
+foo:
+       .byte 0
+       .globl  bar
+bar:
+       .dc.a   foo
 
--- /dev/null
+# as: --64
+# ld: -m elf_x86_64 -shared -z text
+# error: warning: relocation in readonly section `.text'
 
--- /dev/null
+       .text
+foo:
+       .byte 0
+       .globl  bar
+bar:
+       .dc.a   foo
 
 run_dump_test "mov1b"
 run_dump_test "mov1c"
 run_dump_test "mov1d"
+run_dump_test "pr17935-1"
+run_dump_test "pr17935-2"
 
 # Must be native with the C compiler
 if { [isnative] && [which $CC] != 0 } {