diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-08-01 16:02:39 -0700 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-09-21 22:17:45 +0930 |
commit | dc2474e7d204c124ab5a21b4490aa46eb7e1d4c3 (patch) | |
tree | 1bfdd23c35741ebbb64bc8cdb6aca5e886e0a7c7 | |
parent | f184ba116ed615b29302c589c46b255093bb25ca (diff) | |
download | gdb-dc2474e7d204c124ab5a21b4490aa46eb7e1d4c3.zip gdb-dc2474e7d204c124ab5a21b4490aa46eb7e1d4c3.tar.gz gdb-dc2474e7d204c124ab5a21b4490aa46eb7e1d4c3.tar.bz2 |
elf: Reset alignment for each PT_LOAD segment
Reset alignment for each PT_LOAD segment to avoid using alignment from
the previous PT_LOAD segment.
bfd/
PR ld/29435
* elf.c (assign_file_positions_for_load_sections): Reset
alignment for each PT_LOAD segment.
ld/
PR ld/29435
* testsuite/ld-elf/pr29435.d: New file.
* testsuite/ld-elf/pr29435.s: Likewise.
(cherry picked from commit 59f214544c50ec7ebbca285ff2b4949f48671690)
-rw-r--r-- | bfd/elf.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr29435.d | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr29435.s | 6 |
3 files changed, 21 insertions, 3 deletions
@@ -5435,8 +5435,6 @@ assign_file_positions_for_load_sections (bfd *abfd, Elf_Internal_Phdr *p; file_ptr off; /* Octets. */ bfd_size_type maxpagesize; - bfd_size_type p_align; - bool p_align_p = false; unsigned int alloc, actual; unsigned int i, j; struct elf_segment_map **sorted_seg_map; @@ -5521,7 +5519,6 @@ assign_file_positions_for_load_sections (bfd *abfd, qsort (sorted_seg_map, alloc, sizeof (*sorted_seg_map), elf_sort_segments); - p_align = bed->p_align; maxpagesize = 1; if ((abfd->flags & D_PAGED) != 0) { @@ -5556,6 +5553,8 @@ assign_file_positions_for_load_sections (bfd *abfd, asection **secpp; bfd_vma off_adjust; /* Octets. */ bool no_contents; + bfd_size_type p_align; + bool p_align_p; /* An ELF segment (described by Elf_Internal_Phdr) may contain a number of sections with contents contributing to both p_filesz @@ -5566,6 +5565,8 @@ assign_file_positions_for_load_sections (bfd *abfd, p = phdrs + m->idx; p->p_type = m->p_type; p->p_flags = m->p_flags; + p_align = bed->p_align; + p_align_p = false; if (m->count == 0) p->p_vaddr = m->p_vaddr_offset * opb; diff --git a/ld/testsuite/ld-elf/pr29435.d b/ld/testsuite/ld-elf/pr29435.d new file mode 100644 index 0000000..4ca4fd0 --- /dev/null +++ b/ld/testsuite/ld-elf/pr29435.d @@ -0,0 +1,11 @@ +#ld: -shared -z separate-code -z relro +#xfail: ![check_shared_lib_support] +#xfail: ![check_relro_support] +#readelf: -Wl + +#failif +#... + +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ .* 0x8000 +#... + +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ .* 0x8000 +#... diff --git a/ld/testsuite/ld-elf/pr29435.s b/ld/testsuite/ld-elf/pr29435.s new file mode 100644 index 0000000..d2d8f26 --- /dev/null +++ b/ld/testsuite/ld-elf/pr29435.s @@ -0,0 +1,6 @@ + .text + .balign 0x8000 + .globl foo + .type foo, %function +foo: + .byte 0 |