From b733bcb7f58c42e0e0d94a3f266a4193030e5f3a Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 27 Dec 2016 20:50:47 -0800 Subject: Place copy relocations in .dynbss when target is read-only. gold/ PR ld/20995 * copy-relocs.cc (Copy_relocs::make_copy_reloc): Use .dynbss for read-only data when linking with -z relro. * copy-relocs.h (Copy_relocs::dynrelro_): New data member. * testsuite/Makefile.am (copy_test_relro): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/copy_test_relro.cc: New source file. * testsuite/copy_test_relro_1.cc: New source file. --- gold/copy-relocs.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gold/copy-relocs.h') diff --git a/gold/copy-relocs.h b/gold/copy-relocs.h index aa42c7c..92b2ceb 100644 --- a/gold/copy-relocs.h +++ b/gold/copy-relocs.h @@ -54,7 +54,8 @@ class Copy_relocs public: Copy_relocs(unsigned int copy_reloc_type) - : entries_(), copy_reloc_type_(copy_reloc_type), dynbss_(NULL) + : entries_(), copy_reloc_type_(copy_reloc_type), dynbss_(NULL), + dynrelro_(NULL) { } // This is called while scanning relocs if we see a relocation @@ -152,8 +153,11 @@ class Copy_relocs // The target specific relocation type of the COPY relocation. const unsigned int copy_reloc_type_; // The dynamic BSS data which goes into the .bss section. This is - // where variables which require COPY relocations are placed. + // where writable variables which require COPY relocations are placed. Output_data_space* dynbss_; + // The dynamic read-only data, which goes into the .dynbss section. This + // is where read-only variables which require COPY relocations are placed. + Output_data_space* dynrelro_; }; } // End namespace gold. -- cgit v1.1