aboutsummaryrefslogtreecommitdiff
path: root/gold/object.cc
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-12-02 05:42:36 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-12-02 05:43:04 -0800
commit5f6c22aee74f17393b82934a5682d985672e011a (patch)
treefb4a7272b32272ff0b678b1482d61073d55c45d7 /gold/object.cc
parent3134061ce6e33ade4cc65a36578b94983228815e (diff)
downloadfsf-binutils-gdb-5f6c22aee74f17393b82934a5682d985672e011a.zip
fsf-binutils-gdb-5f6c22aee74f17393b82934a5682d985672e011a.tar.gz
fsf-binutils-gdb-5f6c22aee74f17393b82934a5682d985672e011a.tar.bz2
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.
Diffstat (limited to 'gold/object.cc')
-rw-r--r--gold/object.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/gold/object.cc b/gold/object.cc
index cbeddb9..7930de6 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -751,11 +751,13 @@ build_compressed_section_map(
const unsigned char* contents =
obj->section_contents(i, &len, false);
uint64_t uncompressed_size;
+ Compressed_section_info info;
if (is_zcompressed)
{
// Skip over the ".zdebug" prefix.
name += 7;
uncompressed_size = get_uncompressed_size(contents, len);
+ info.addralign = shdr.get_sh_addralign();
}
else
{
@@ -763,8 +765,8 @@ build_compressed_section_map(
name += 6;
elfcpp::Chdr<size, big_endian> chdr(contents);
uncompressed_size = chdr.get_ch_size();
+ info.addralign = chdr.get_ch_addralign();
}
- Compressed_section_info info;
info.size = convert_to_section_size_type(uncompressed_size);
info.flag = shdr.get_sh_flags();
info.contents = NULL;
@@ -3064,7 +3066,8 @@ const unsigned char*
Object::decompressed_section_contents(
unsigned int shndx,
section_size_type* plen,
- bool* is_new)
+ bool* is_new,
+ uint64_t* palign)
{
section_size_type buffer_size;
const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size,
@@ -3091,6 +3094,8 @@ Object::decompressed_section_contents(
{
*plen = uncompressed_size;
*is_new = false;
+ if (palign != NULL)
+ *palign = p->second.addralign;
return p->second.contents;
}
@@ -3112,6 +3117,8 @@ Object::decompressed_section_contents(
// once in this pass.
*plen = uncompressed_size;
*is_new = true;
+ if (palign != NULL)
+ *palign = p->second.addralign;
return uncompressed_data;
}