diff options
author | Ian Lance Taylor <ian@airs.com> | 2011-07-13 22:47:08 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2011-07-13 22:47:08 +0000 |
commit | 9446efde0abc5a3cff716eb2879bf99e3251165f (patch) | |
tree | bd6e9ba7326f0617dfa3acc50d0dab8d3fef2c0d /gold/x86_64.cc | |
parent | 67f41397ce652a92b8160eb15de66c33b598a376 (diff) | |
download | gdb-9446efde0abc5a3cff716eb2879bf99e3251165f.zip gdb-9446efde0abc5a3cff716eb2879bf99e3251165f.tar.gz gdb-9446efde0abc5a3cff716eb2879bf99e3251165f.tar.bz2 |
* i386.cc (Target_i386::got_section): If -z now, make .got.plt a
relro section.
* x86_64.cc (Target_x86_64::got_section): Likewise.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_now_test.
(relro_now_test_SOURCES): New variable.
(relro_now_test_DEPENDENCIES): New variable.
(relro_now_test_LDFLAGS): New variable.
(relro_now_test_LDADD): New variable.
(relro_now_test.so): New target.
* testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/x86_64.cc')
-rw-r--r-- | gold/x86_64.cc | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/gold/x86_64.cc b/gold/x86_64.cc index ef66737..4025527 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -834,26 +834,39 @@ Target_x86_64::got_section(Symbol_table* symtab, Layout* layout) { gold_assert(symtab != NULL && layout != NULL); + // When using -z now, we can treat .got.plt as a relro section. + // Without -z now, it is modified after program startup by lazy + // PLT relocations. + bool is_got_plt_relro = parameters->options().now(); + Output_section_order got_order = (is_got_plt_relro + ? ORDER_RELRO + : ORDER_RELRO_LAST); + Output_section_order got_plt_order = (is_got_plt_relro + ? ORDER_RELRO + : ORDER_NON_RELRO_FIRST); + this->got_ = new Output_data_got<64, false>(); layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS, (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), - this->got_, ORDER_RELRO_LAST, - true); + this->got_, got_order, true); this->got_plt_ = new Output_data_space(8, "** GOT PLT"); layout->add_output_section_data(".got.plt", elfcpp::SHT_PROGBITS, (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), - this->got_plt_, ORDER_NON_RELRO_FIRST, - false); + this->got_plt_, got_plt_order, + is_got_plt_relro); // The first three entries are reserved. this->got_plt_->set_current_data_size(3 * 8); - // Those bytes can go into the relro segment. - layout->increase_relro(3 * 8); + if (!is_got_plt_relro) + { + // Those bytes can go into the relro segment. + layout->increase_relro(3 * 8); + } // Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT. this->global_offset_table_ = @@ -872,7 +885,7 @@ Target_x86_64::got_section(Symbol_table* symtab, Layout* layout) (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), this->got_irelative_, - ORDER_NON_RELRO_FIRST, false); + got_plt_order, is_got_plt_relro); // If there are any TLSDESC relocations, they get GOT entries in // .got.plt after the jump slot and IRELATIVE entries. @@ -881,7 +894,7 @@ Target_x86_64::got_section(Symbol_table* symtab, Layout* layout) (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE), this->got_tlsdesc_, - ORDER_NON_RELRO_FIRST, false); + got_plt_order, is_got_plt_relro); } return this->got_; |