diff options
author | Cary Coutant <ccoutant@google.com> | 2010-11-16 18:40:28 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2010-11-16 18:40:28 +0000 |
commit | 6fc6ea198c7feb48e378a490f5d227d625a340e4 (patch) | |
tree | 02aa19e7f2893c86b5d8a43792f840fcfa596589 /gold | |
parent | a0692e366ae31b249502c7c60d7091211f680c68 (diff) | |
download | gdb-6fc6ea198c7feb48e378a490f5d227d625a340e4.zip gdb-6fc6ea198c7feb48e378a490f5d227d625a340e4.tar.gz gdb-6fc6ea198c7feb48e378a490f5d227d625a340e4.tar.bz2 |
PR gold/12220
* layout.cc (Layout::choose_output_section): Transform names of
compressed sections even when using a script with a SECTIONS clause.
(Layout::output_section_name): Remove code to transform
compressed debug section names.
* output.cc (Output_section::add_input_section): Use uncompressed
section size when tracking input sections.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 10 | ||||
-rw-r--r-- | gold/layout.cc | 83 | ||||
-rw-r--r-- | gold/output.cc | 2 |
3 files changed, 54 insertions, 41 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index f7448b9..c48ea60 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,13 @@ +2010-11-16 Cary Coutant <ccoutant@google.com> + + PR gold/12220 + * layout.cc (Layout::choose_output_section): Transform names of + compressed sections even when using a script with a SECTIONS clause. + (Layout::output_section_name): Remove code to transform + compressed debug section names. + * output.cc (Output_section::add_input_section): Use uncompressed + section size when tracking input sections. + 2010-11-11 Richard Sandiford <richard.sandiford@linaro.org> * symtab.h (Symbol::NON_PIC_REF): Remove. diff --git a/gold/layout.cc b/gold/layout.cc index be4bb5c..f5784fb 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -288,6 +288,30 @@ is_lines_only_debug_section(const char* str) return false; } +// Sometimes we compress sections. This is typically done for +// sections that are not part of normal program execution (such as +// .debug_* sections), and where the readers of these sections know +// how to deal with compressed sections. This routine doesn't say for +// certain whether we'll compress -- it depends on commandline options +// as well -- just whether this section is a candidate for compression. +// (The Output_compressed_section class decides whether to compress +// a given section, and picks the name of the compressed section.) + +static bool +is_compressible_debug_section(const char* secname) +{ + return (is_prefix_of(".debug", secname)); +} + +// We may see compressed debug sections in input files. Return TRUE +// if this is the name of a compressed debug section. + +bool +is_compressed_debug_section(const char* secname) +{ + return (is_prefix_of(".zdebug", secname)); +} + // Whether to include this section in the link. template<int size, bool big_endian> @@ -581,10 +605,24 @@ Layout::choose_output_section(const Relobj* relobj, const char* name, // FIXME: Handle SHF_OS_NONCONFORMING somewhere. + size_t len = strlen(name); + char* uncompressed_name = NULL; + + // Compressed debug sections should be mapped to the corresponding + // uncompressed section. + if (is_compressed_debug_section(name)) + { + uncompressed_name = new char[len]; + uncompressed_name[0] = '.'; + gold_assert(name[0] == '.' && name[1] == 'z'); + strncpy(&uncompressed_name[1], &name[2], len - 2); + uncompressed_name[len - 1] = '\0'; + len -= 1; + name = uncompressed_name; + } + // Turn NAME from the name of the input section into the name of the // output section. - - size_t len = strlen(name); if (is_input_section && !this->script_options_->saw_sections_clause() && !parameters->options().relocatable()) @@ -593,6 +631,9 @@ Layout::choose_output_section(const Relobj* relobj, const char* name, Stringpool::Key name_key; name = this->namepool_.add_with_length(name, len, true, &name_key); + if (uncompressed_name != NULL) + delete[] uncompressed_name; + // Find or make the output section. The output section is selected // based on the section name, type, and flags. return this->get_output_section(name, name_key, type, flags, order, is_relro); @@ -925,30 +966,6 @@ Layout::section_flags_to_segment(elfcpp::Elf_Xword flags) return ret; } -// Sometimes we compress sections. This is typically done for -// sections that are not part of normal program execution (such as -// .debug_* sections), and where the readers of these sections know -// how to deal with compressed sections. This routine doesn't say for -// certain whether we'll compress -- it depends on commandline options -// as well -- just whether this section is a candidate for compression. -// (The Output_compressed_section class decides whether to compress -// a given section, and picks the name of the compressed section.) - -static bool -is_compressible_debug_section(const char* secname) -{ - return (is_prefix_of(".debug", secname)); -} - -// We may see compressed debug sections in input files. Return TRUE -// if this is the name of a compressed debug section. - -bool -is_compressed_debug_section(const char* secname) -{ - return (is_prefix_of(".zdebug", secname)); -} - // Make a new Output_section, and attach it to segments as // appropriate. ORDER is the order in which this section should // appear in the output segment. IS_RELRO is true if this is a relro @@ -3924,20 +3941,6 @@ Layout::output_section_name(const char* name, size_t* plen) } } - // Compressed debug sections should be mapped to the corresponding - // uncompressed section. - if (is_compressed_debug_section(name)) - { - size_t len = strlen(name); - char* uncompressed_name = new char[len]; - uncompressed_name[0] = '.'; - gold_assert(name[0] == '.' && name[1] == 'z'); - strncpy(&uncompressed_name[1], &name[2], len - 2); - uncompressed_name[len - 1] = '\0'; - *plen = len - 1; - return uncompressed_name; - } - return name; } diff --git a/gold/output.cc b/gold/output.cc index dda475d..766e0ff 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -2165,7 +2165,7 @@ Output_section::add_input_section(Layout* layout, || parameters->target().may_relax() || parameters->options().section_ordering_file()) { - Input_section isecn(object, shndx, shdr.get_sh_size(), addralign); + Input_section isecn(object, shndx, input_section_size, addralign); if (parameters->options().section_ordering_file()) { unsigned int section_order_index = |