aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-10-27 00:36:52 +0000
committerIan Lance Taylor <iant@google.com>2007-10-27 00:36:52 +0000
commitdba5a01fdc5128799e020cc34ba60f8d8c602a9e (patch)
treecbe490523c2cdeba18a626598e5cdaa0eb8db7be /gold/layout.cc
parente3dd034fca239d8ee7352647d185b890d47fc022 (diff)
downloadgdb-dba5a01fdc5128799e020cc34ba60f8d8c602a9e.zip
gdb-dba5a01fdc5128799e020cc34ba60f8d8c602a9e.tar.gz
gdb-dba5a01fdc5128799e020cc34ba60f8d8c602a9e.tar.bz2
From Cary Coutant: Set offsets of sections with data before finalizing
local symbols.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index 22d3b59..488ca6d 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -633,15 +633,20 @@ Layout::finalize(const Input_objects* input_objects, Symbol_table* symtab)
// they contain.
off_t off = this->set_segment_offsets(target, load_seg, &shndx);
+ // Set the file offsets of all the data sections not associated with
+ // segments. This makes sure that debug sections have their offsets
+ // before symbols are finalized.
+ off = this->set_section_offsets(off, &shndx, true);
+
// Create the symbol table sections.
this->create_symtab_sections(input_objects, symtab, &off);
// Create the .shstrtab section.
Output_section* shstrtab_section = this->create_shstrtab();
- // Set the file offsets of all the sections not associated with
+ // Set the file offsets of all the non-data sections not associated with
// segments.
- off = this->set_section_offsets(off, &shndx);
+ off = this->set_section_offsets(off, &shndx, false);
// Create the section table header.
Output_section_headers* oshdrs = this->create_shdrs(&off);
@@ -986,12 +991,18 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg,
// segment.
off_t
-Layout::set_section_offsets(off_t off, unsigned int* pshndx)
+Layout::set_section_offsets(off_t off,
+ unsigned int* pshndx,
+ bool do_bits_sections)
{
for (Section_list::iterator p = this->unattached_section_list_.begin();
p != this->unattached_section_list_.end();
++p)
{
+ bool is_bits_section = ((*p)->type() == elfcpp::SHT_PROGBITS
+ || (*p)->type() == elfcpp::SHT_NOBITS);
+ if (is_bits_section != do_bits_sections)
+ continue;
(*p)->set_out_shndx(*pshndx);
++*pshndx;
if ((*p)->offset() != -1)