svn commit: r312891 - projects/clang400-import/contrib/llvm/tools/lld/ELF
Ed Maste
emaste at FreeBSD.org
Fri Jan 27 16:53:55 UTC 2017
Author: emaste
Date: Fri Jan 27 16:53:53 2017
New Revision: 312891
URL: https://svnweb.freebsd.org/changeset/base/312891
Log:
lld: do not round up PT_GNU_RELRO p_memsz
The change was made to support glibc and believed to be a no-op on
FreeBSD, but that is not the case for architectures with multiple page
sizes, such as arm64. The relro p_memsz header was rounded up to the
default maximum page size (64K). When 4K pages are in use, multiple
pages beyond the final PT_LOAD segment had their permissions changed to
read-only after application of relocations and copy relocations, which
led to a segfault in certain cases.
This reverts upstream r290986. I have started a discussion about the
upstream fix on the LLVM mailing list.
Reported by: andrew
Sponsored by: The FreeBSD Foundation
Modified:
projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp
Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp Fri Jan 27 15:03:51 2017 (r312890)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp Fri Jan 27 16:53:53 2017 (r312891)
@@ -1461,13 +1461,8 @@ template <class ELFT> void Writer<ELFT>:
}
if (P.p_type == PT_LOAD)
P.p_align = Config->MaxPageSize;
- else if (P.p_type == PT_GNU_RELRO) {
+ else if (P.p_type == PT_GNU_RELRO)
P.p_align = 1;
- // The glibc dynamic loader rounds the size down, so we need to round up
- // to protect the last page. This is a no-op on FreeBSD which always
- // rounds up.
- P.p_memsz = alignTo(P.p_memsz, Config->MaxPageSize);
- }
// The TLS pointer goes after PT_TLS. At least glibc will align it,
// so round up the size to make sure the offsets are correct.
More information about the svn-src-projects
mailing list