[gold patch] Fix PR gold/12220 where linker script causes internal error with compressed debug sections
Cary Coutant
ccoutant@google.com
Tue Nov 16 18:49:00 GMT 2010
More information about the Binutils mailing list
Tue Nov 16 18:49:00 GMT 2010
- Previous message (by thread): [gold patch] Fix PR gold/12220 where linker script causes internal error with compressed debug sections
- Next message (by thread): [gold patch] Fix PR gold/12220 where linker script causes internal error with compressed debug sections
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> If the code takes this path, it should free the allocated memory after
> the call to this->namepool_.add_with_length.
>
> Also now please remove the handling of is_compressed_debug_section in
> Layout::output_section_name.
Oops! I meant to remove that.
Here's the patch as committed. (Sorry, I forgot to include ChangeLog
in the commit, and had to commit it separately.)
-cary
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.
-------------- next part --------------
Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.186
diff -u -p -r1.186 layout.cc
--- layout.cc 9 Nov 2010 07:56:10 -0000 1.186
+++ layout.cc 16 Nov 2010 18:31:20 -0000
@@ -288,6 +288,30 @@ is_lines_only_debug_section(const char*
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 Relo
// 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 Relo
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:
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*
}
}
- // 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;
}
Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.137
diff -u -p -r1.137 output.cc
--- output.cc 29 Oct 2010 20:49:20 -0000 1.137
+++ output.cc 16 Nov 2010 18:31:20 -0000
@@ -2165,7 +2165,7 @@ Output_section::add_input_section(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 =
- Previous message (by thread): [gold patch] Fix PR gold/12220 where linker script causes internal error with compressed debug sections
- Next message (by thread): [gold patch] Fix PR gold/12220 where linker script causes internal error with compressed debug sections
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list