diff options
author | Alan Modra <amodra@gmail.com> | 2015-07-28 11:03:57 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-07-28 18:42:43 +0930 |
commit | e5654c0f8492e65b3e3ac5e1a2276856049eb1b1 (patch) | |
tree | 365260c36ca9ad4abda3550eec856dcce63beba8 /bfd/elf.c | |
parent | d6f1bafa2c05241b89c0303a9f6a2af89f51c39c (diff) | |
download | gdb-e5654c0f8492e65b3e3ac5e1a2276856049eb1b1.zip gdb-e5654c0f8492e65b3e3ac5e1a2276856049eb1b1.tar.gz gdb-e5654c0f8492e65b3e3ac5e1a2276856049eb1b1.tar.bz2 |
Fallout from "Reorder more powerpc64 sections for -z relro"
Commit 23283c1b changed the layout of some bss style sections on
powerpc64, but neglected to add a page gap before the third PT_LOAD
segment created by this reording. Without a page gap we get two
PT_LOAD headers that overlap by one page in memory. That shouldn't be
allowed because the dynamic loader will load garbage from the first
page of the last segment over the last page of the previous segment.
bfd/
* elf.c (_bfd_elf_map_sections_to_segments): Do not make a new
segment for loaded sections after nonloaded sections if the
sections are on the same page.
ld/testsuite/
* ld-powerpc/elfv2so.d: Update
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -4220,11 +4220,18 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) new_segment = TRUE; } else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0 - && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0) + && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0 + && ((abfd->flags & D_PAGED) == 0 + || (((last_hdr->lma + last_size - 1) & -maxpagesize) + != (hdr->lma & -maxpagesize)))) { - /* We don't want to put a loadable section after a - nonloadable section in the same segment. - Consider .tbss sections as loadable for this purpose. */ + /* We don't want to put a loaded section after a + nonloaded (ie. bss style) section in the same segment + as that will force the non-loaded section to be loaded. + Consider .tbss sections as loaded for this purpose. + However, like the writable/non-writable case below, + if they are on the same page then they must be put + in the same segment. */ new_segment = TRUE; } else if ((abfd->flags & D_PAGED) == 0) |