+2016-12-28 Alan Modra <amodra@gmail.com>
+
+ PR ld/20995
+ * elflink.c (elf_link_add_object_symbols): Mark relro sections
+ in dynamic objects SEC_READONLY.
+
2016-12-26 Alan Modra <amodra@gmail.com>
PR ld/20995
const char *soname = NULL;
char *audit = NULL;
struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
+ const Elf_Internal_Phdr *phdr;
int ret;
/* ld --just-symbols and dynamic objects don't mix very well.
*pn = rpath;
}
+ /* If we have a PT_GNU_RELRO program header, mark as read-only
+ all sections contained fully therein. This makes relro
+ shared library sections appear as they will at run-time. */
+ phdr = elf_tdata (abfd)->phdr + elf_elfheader (abfd)->e_phnum;
+ while (--phdr >= elf_tdata (abfd)->phdr)
+ if (phdr->p_type == PT_GNU_RELRO)
+ {
+ for (s = abfd->sections; s != NULL; s = s->next)
+ if ((s->flags & SEC_ALLOC) != 0
+ && s->vma >= phdr->p_vaddr
+ && s->vma + s->size <= phdr->p_vaddr + phdr->p_memsz)
+ s->flags |= SEC_READONLY;
+ break;
+ }
+
/* We do not want to include any of the sections in a dynamic
object in the output file. We hack by simply clobbering the
list of sections in the BFD. This could be handled more
+2016-12-28 Alan Modra <amodra@gmail.com>
+
+ PR ld/20995
+ * testsuite/ld-elf/pr20995c.s: New test file.
+ * testsuite/ld-elf/pr20995-2so.r: Likewise.
+ * testsuite/ld-elf/elf.exp: Run it.
+
2016-12-26 Alan Modra <amodra@gmail.com>
PR ld/20995
"-shared" "" ""
{pr20995b.s} {} "pr20995.so"}
}
+ setup_xfail "tic6x-*-*"
+ run_ld_link_tests {
+ {"Build pr20995-2.so"
+ "-shared -z relro" "" ""
+ {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"}
+ }
# These targets don't copy dynamic variables into .bss.
setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
run_ld_link_tests {
"" "tmpdir/pr20995.so" ""
{pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"}
}
+ setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
+ run_ld_link_tests {
+ {"pr20995-2"
+ "" "tmpdir/pr20995-2.so" ""
+ {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"}
+ }
}
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
--- /dev/null
+#...
+ GNU_RELRO .*
+#pass
--- /dev/null
+ .data
+ .type rw,%object
+ .globl rw
+rw:
+ .dc.a 0
+ .size rw, . - rw
+
+ .section .data.rel.ro,"aw",%progbits
+ .type ro,%object
+ .globl ro
+ro:
+ .dc.a 0
+ .size ro, . - ro