aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2012-03-15 18:24:06 +0000
committerDoug Kwan <dougkwan@google.com>2012-03-15 18:24:06 +0000
commit7b8957f8c3b4054061363abdc38bbbf0a3b20635 (patch)
treefb853cfc2d51b95150eace78ef1b8ae951c1928e
parenta4456d242dd59e4f0ccad3020667df19be2202e8 (diff)
downloadgdb-7b8957f8c3b4054061363abdc38bbbf0a3b20635.zip
gdb-7b8957f8c3b4054061363abdc38bbbf0a3b20635.tar.gz
gdb-7b8957f8c3b4054061363abdc38bbbf0a3b20635.tar.bz2
2012-03-15 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::got_section): Make .got section read-only if -z now is given.
-rw-r--r--gold/ChangeLog5
-rw-r--r--gold/arm.cc15
2 files changed, 18 insertions, 2 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 0c1a7e1..4479618 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-15 Doug Kwan <dougkwan@google.com>
+
+ * arm.cc (Target_arm::got_section): Make .got section read-only
+ if -z now is given.
+
2012-03-15 Ian Lance Taylor <iant@google.com>
PR gold/13850
diff --git a/gold/arm.cc b/gold/arm.cc
index 04004a6..32a4638 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -4174,11 +4174,22 @@ Target_arm<big_endian>::got_section(Symbol_table* symtab, Layout* layout)
{
gold_assert(symtab != NULL && layout != NULL);
+ // When using -z now, we can treat .got as a relro section.
+ // Without -z now, it is modified after program startup by lazy
+ // PLT relocations.
+ bool is_got_relro = parameters->options().now();
+ Output_section_order got_order = (is_got_relro
+ ? ORDER_RELRO_LAST
+ : ORDER_DATA);
+
+ // Unlike some targets (.e.g x86), ARM does not use separate .got and
+ // .got.plt sections in output. The output .got section contains both
+ // PLT and non-PLT GOT entries.
this->got_ = new Arm_output_data_got<big_endian>(symtab, layout);
layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
(elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE),
- this->got_, ORDER_DATA, false);
+ this->got_, got_order, is_got_relro);
// The old GNU linker creates a .got.plt section. We just
// create another set of data in the .got section. Note that we
@@ -4187,7 +4198,7 @@ Target_arm<big_endian>::got_section(Symbol_table* symtab, Layout* layout)
this->got_plt_ = new Output_data_space(4, "** GOT PLT");
layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
(elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE),
- this->got_plt_, ORDER_DATA, false);
+ this->got_plt_, got_order, is_got_relro);
// The first three entries are reserved.
this->got_plt_->set_current_data_size(3 * 4);