gold: Get alignment of uncompressed section from ch_addralign

The ELF compression header has a field (ch_addralign) that is set to
the alignment of the uncompressed section. This way the section itself
can have a different alignment than the decompressed section.  Update
decompress_input_section to get alignment of the decompressed section
and use it when merging decompressed strings.

	PR binutils/23919
	* merge.cc (Output_merge_string<Char_type>::do_add_input_section):
	Get addralign from decompressed_section_contents.
	* object.cc (build_compressed_section_map): Set info.addralign.
	(Object::decompressed_section_contents): Add a palign
	argument and store p->second.addralign in *palign if it isn't
	NULL.
	* object.h (Compressed_section_info): Add addralign.
	(section_is_compressed): Add a palign argument, default it
	to NULL, store p->second.addralign in *palign if it isn't NULL.
	(Object::decompressed_section_contents): Likewise.
	* output.cc (Output_section::add_input_section): Get addralign
	from section_is_compressed.
This commit is contained in:
H.J. Lu
2018-12-02 05:42:36 -08:00
parent 3134061ce6
commit 5f6c22aee7
5 changed files with 42 additions and 12 deletions

View File

@@ -440,9 +440,11 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
{
section_size_type sec_len;
bool is_new;
uint64_t addralign = this->addralign();
const unsigned char* pdata = object->decompressed_section_contents(shndx,
&sec_len,
&is_new);
&is_new,
&addralign);
const Char_type* p = reinterpret_cast<const Char_type*>(pdata);
const Char_type* pend = p + sec_len / sizeof(Char_type);
@@ -494,7 +496,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
// aligned, so each string within the section must retain the same
// modulo.
uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata)
& (this->addralign() - 1));
& (addralign - 1));
bool has_misaligned_strings = false;
while (p < pend)
@@ -503,7 +505,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
// Within merge input section each string must be aligned.
if (len != 0
&& ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1))
&& ((reinterpret_cast<uintptr_t>(p) & (addralign - 1))
!= init_align_modulo))
has_misaligned_strings = true;