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.
This commit is contained in:
parent
a0692e366a
commit
6fc6ea198c
3 changed files with 54 additions and 41 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Reference in a new issue