diff options
author | Ian Lance Taylor <iant@google.com> | 2008-02-12 00:24:00 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2008-02-12 00:24:00 +0000 |
commit | 4e8fe71f6c6f417efb67675695fa0b96cf6081b5 (patch) | |
tree | 67853f43415409a109d624501aaccd1ec73adad7 /gold | |
parent | 0e43bb4edd02c76feb1735e057ea302be13404a9 (diff) | |
download | gdb-4e8fe71f6c6f417efb67675695fa0b96cf6081b5.zip gdb-4e8fe71f6c6f417efb67675695fa0b96cf6081b5.tar.gz gdb-4e8fe71f6c6f417efb67675695fa0b96cf6081b5.tar.bz2 |
Set TEXTREL correctly when using a SECTIONS clause.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/layout.cc | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/gold/layout.cc b/gold/layout.cc index 6cba3aa..b28682e 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -2168,16 +2168,38 @@ Layout::finish_dynamic_section(const Input_objects* input_objects, // Look for text segments that have dynamic relocations. bool have_textrel = false; - for (Segment_list::const_iterator p = this->segment_list_.begin(); - p != this->segment_list_.end(); - ++p) + if (!this->script_options_->saw_sections_clause()) { - if (((*p)->flags() & elfcpp::PF_W) == 0 - && (*p)->dynamic_reloc_count() > 0) - { - have_textrel = true; - break; - } + for (Segment_list::const_iterator p = this->segment_list_.begin(); + p != this->segment_list_.end(); + ++p) + { + if (((*p)->flags() & elfcpp::PF_W) == 0 + && (*p)->dynamic_reloc_count() > 0) + { + have_textrel = true; + break; + } + } + } + else + { + // We don't know the section -> segment mapping, so we are + // conservative and just look for readonly sections with + // relocations. If those sections wind up in writable segments, + // then we have created an unnecessary DT_TEXTREL entry. + for (Section_list::const_iterator p = this->section_list_.begin(); + p != this->section_list_.end(); + ++p) + { + if (((*p)->flags() & elfcpp::SHF_ALLOC) != 0 + && ((*p)->flags() & elfcpp::SHF_WRITE) == 0 + && ((*p)->dynamic_reloc_count() > 0)) + { + have_textrel = true; + break; + } + } } // Add a DT_FLAGS entry. We add it even if no flags are set so that |