aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-08-20 15:03:21 +0100
committerNick Clifton <nickc@redhat.com>2020-08-20 15:03:21 +0100
commit01147b208215ae457e7ef2d5a105c9dac93d955a (patch)
treefbc5c694550b48165a1c707154633794a660bcc9
parent33bf4c5c10d246543c7a9a8ba4bbbe173d7f3367 (diff)
downloadgdb-01147b208215ae457e7ef2d5a105c9dac93d955a.zip
gdb-01147b208215ae457e7ef2d5a105c9dac93d955a.tar.gz
gdb-01147b208215ae457e7ef2d5a105c9dac93d955a.tar.bz2
Ensure that compressed sections that have an ELF compression header structure at the start are correctly aligned.
PR 26428 bfd * bfd.c (bfd_update_compression_header): Also set the sh_addralign field in the ELF header of the compressed sections. ld * testsuite/ld-elf/zlibbegin.rS: Update expected output. * testsuite/ld-elf/zlibnormal.rS: Likewise.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/bfd.c3
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/testsuite/ld-elf/zlibbegin.rS2
-rw-r--r--ld/testsuite/ld-elf/zlibnormal.rS2
5 files changed, 17 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8c43a16..670803d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2020-08-20 Nick Clifton <nickc@redhat.com>
+ PR 26428
+ * bfd.c (bfd_update_compression_header): Also set the sh_addralign
+ field in the ELF header of the compressed sections.
+
+2020-08-20 Nick Clifton <nickc@redhat.com>
+
PR 26406
* elf-bfd.h (struct bfd_elf_section_data): Add
has_secondary_relocs field.
diff --git a/bfd/bfd.c b/bfd/bfd.c
index ec38a06..449bcc6 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2558,6 +2558,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
if ((abfd->flags & BFD_COMPRESS_GABI) != 0)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ struct bfd_elf_section_data * esd = elf_section_data (sec);
/* Set the SHF_COMPRESSED bit. */
elf_section_flags (sec) |= SHF_COMPRESSED;
@@ -2571,6 +2572,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
&echdr->ch_addralign);
/* bfd_log2 (alignof (Elf32_Chdr)) */
bfd_set_section_alignment (sec, 2);
+ esd->this_hdr.sh_addralign = 4;
}
else
{
@@ -2582,6 +2584,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
&echdr->ch_addralign);
/* bfd_log2 (alignof (Elf64_Chdr)) */
bfd_set_section_alignment (sec, 3);
+ esd->this_hdr.sh_addralign = 8;
}
break;
}
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 973c000..0e3a859 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2020-08-20 Nick Clifton <nickc@redhat.com>
+
+ PR 26428
+ * testsuite/ld-elf/zlibbegin.rS: Update expected output.
+ * testsuite/ld-elf/zlibnormal.rS: Likewise.
+
2020-08-16 Alan Modra <amodra@gmail.com>
* testsuite/ld-powerpc/inline.s,
diff --git a/ld/testsuite/ld-elf/zlibbegin.rS b/ld/testsuite/ld-elf/zlibbegin.rS
index dbab80c..c34a0f8 100644
--- a/ld/testsuite/ld-elf/zlibbegin.rS
+++ b/ld/testsuite/ld-elf/zlibbegin.rS
@@ -1,3 +1,3 @@
#...
- +\[[ 0-9]+\] .debug_.* +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +G?C +0 +0 +1
+ +\[[ 0-9]+\] .debug_.* +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +G?C +0 +0 +[48]
#pass
diff --git a/ld/testsuite/ld-elf/zlibnormal.rS b/ld/testsuite/ld-elf/zlibnormal.rS
index dbab80c..c34a0f8 100644
--- a/ld/testsuite/ld-elf/zlibnormal.rS
+++ b/ld/testsuite/ld-elf/zlibnormal.rS
@@ -1,3 +1,3 @@
#...
- +\[[ 0-9]+\] .debug_.* +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +G?C +0 +0 +1
+ +\[[ 0-9]+\] .debug_.* +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +G?C +0 +0 +[48]
#pass