diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-05-20 04:00:47 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-05-20 04:00:47 +0000 |
commit | 9f1d377b33ab688f86e1cc9a454d87f991d65f19 (patch) | |
tree | c1b3a61a840a01d29858641f0db6b017124501d4 /gold/output.h | |
parent | 3285cf2c2fa75927a67ef845d47f5eb81770ac21 (diff) | |
download | gdb-9f1d377b33ab688f86e1cc9a454d87f991d65f19.zip gdb-9f1d377b33ab688f86e1cc9a454d87f991d65f19.tar.gz gdb-9f1d377b33ab688f86e1cc9a454d87f991d65f19.tar.bz2 |
* options.h (class General_options): Add -z relro.
* layout.cc (Layout::Layout): Initialize relro_segment_.
(Layout::add_output_section_data): Return the output section.
(Layout::make_output_section): Rcognize relro sections and mark
them appropriately.
(Layout::attach_allocated_section_to_segment): Put relro sections
in a PT_GNU_RELRO segment.
(Layout::create_initial_dynamic_sections): Mark the .dynamic
section as relro.
(Layout::segment_precedes): Sort PT_GNU_RELRO segments after
PT_TLS segments.
(Layout::linkonce_mapping): Map d.rel.ro.local to
.data.rel.ro.local.
(Layout::output_section_name): Us .data.rel.ro.local for any
section which begins with that.
* layout.h (class Layout): Update add_output_section_data
declaration. Add relro_segment_ field.
* output.cc (Output_section::Output_section): Initialize is_relro_
and is_relro_local_ fields.
(Output_segment::add_output_section): Group relro sections.
(Output_segment::is_first_section_relro): New function.
(Output_segment::maximum_alignment): If there is a relro section,
align the segment to the common page size.
(Output_segment::set_section_addresses): Track whether we are
looking at relro sections. If the last section is a relro
section, align to the common page size.
(Output_segment::set_section_list_addresses): Add in_relro
parameter. Change all callers. Align to the page size when
moving from relro to non-relro section.
(Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
segment.
* output.h (class Output_section): Add is_relro_ and
is_relro_local_ fields.
(Output_section::is_relro): New function.
(Output_section::set_is_relro): New function.
(Output_section::is_relro_local): New function.
(Output_section::set_is_relro_local): New function.
(class Output_segment): Update declarations.
* i386.cc (Target_i386::got_section): Mark .got section as relro.
* sparc.cc (Target_sparc::got_section): Likewise.
* x86_64.cc (Target_x86_64::got_section): Likewise.
* testsuite/relro_test_main.cc: New file.
* testsuite/relro_test.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
(relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
(relro_test_LDFLAGS, relro_test_LDADD): New variables.
(relro_test.so, relro_test_pic.o): New targets.
* testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/output.h')
-rw-r--r-- | gold/output.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/gold/output.h b/gold/output.h index b4dbbd1..a8f2f39 100644 --- a/gold/output.h +++ b/gold/output.h @@ -2028,6 +2028,29 @@ class Output_section : public Output_data set_must_sort_attached_input_sections() { this->must_sort_attached_input_sections_ = true; } + // Return whether this section holds relro data--data which has + // dynamic relocations but which may be marked read-only after the + // dynamic relocations have been completed. + bool + is_relro() const + { return this->is_relro_; } + + // Record that this section holds relro data. + void + set_is_relro() + { this->is_relro_ = true; } + + // True if this section holds relro local data--relro data for which + // the dynamic relocations are all RELATIVE relocations. + bool + is_relro_local() const + { return this->is_relro_local_; } + + // Record that this section holds relro local data. + void + set_is_relro_local() + { this->is_relro_local_ = true; } + // Return whether this section should be written after all the input // sections are complete. bool @@ -2626,6 +2649,10 @@ class Output_section : public Output_data // True if the input sections attached to this output section have // already been sorted. bool attached_input_sections_are_sorted_ : 1; + // True if this section holds relro data. + bool is_relro_ : 1; + // True if this section holds relro local data. + bool is_relro_local_ : 1; // For SHT_TLS sections, the offset of this section relative to the base // of the TLS segment. uint64_t tls_offset_; @@ -2785,11 +2812,15 @@ class Output_segment static uint64_t maximum_alignment_list(const Output_data_list*); + // Return whether the first data section is a relro section. + bool + is_first_section_relro() const; + // Set the section addresses in an Output_data_list. uint64_t set_section_list_addresses(const Layout*, bool reset, Output_data_list*, uint64_t addr, off_t* poff, unsigned int* pshndx, - bool* in_tls); + bool* in_tls, bool* in_relro); // Return the number of Output_sections in an Output_data_list. unsigned int |