From owner-svn-src-projects@freebsd.org Fri Jan 27 16:53:55 2017 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B7F0CC31DF for ; Fri, 27 Jan 2017 16:53:55 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D42F4B7; Fri, 27 Jan 2017 16:53:54 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0RGrrO5087500; Fri, 27 Jan 2017 16:53:53 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0RGrrL3087499; Fri, 27 Jan 2017 16:53:53 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201701271653.v0RGrrL3087499@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 27 Jan 2017 16:53:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r312891 - projects/clang400-import/contrib/llvm/tools/lld/ELF X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2017 16:53:55 -0000 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 void Writer: } 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.