diff options
Diffstat (limited to 'gold/layout.cc')
-rw-r--r-- | gold/layout.cc | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/gold/layout.cc b/gold/layout.cc index be4bb5ccde1..f5784fba1b2 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; } |