From owner-svn-src-head@FreeBSD.ORG Sat Feb 22 11:06:48 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F10B82F5; Sat, 22 Feb 2014 11:06:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D9A811BDF; Sat, 22 Feb 2014 11:06:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1MB6meD005350; Sat, 22 Feb 2014 11:06:48 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1MB6mSe005349; Sat, 22 Feb 2014 11:06:48 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201402221106.s1MB6mSe005349@svn.freebsd.org> From: David Xu Date: Sat, 22 Feb 2014 11:06:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262334 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Feb 2014 11:06:49 -0000 Author: davidxu Date: Sat Feb 22 11:06:48 2014 New Revision: 262334 URL: http://svnweb.freebsd.org/changeset/base/262334 Log: Increase alignment to size of pointer if the alignment is too small. Some modules do not align data at least to size of pointer, they uses a smaller alignment, but our pointer should be aligned to its native boundary, otherwise on some platforms, hardware alignment checking will cause bus error. Modified: head/libexec/rtld-elf/xmalloc.c Modified: head/libexec/rtld-elf/xmalloc.c ============================================================================== --- head/libexec/rtld-elf/xmalloc.c Sat Feb 22 10:15:27 2014 (r262333) +++ head/libexec/rtld-elf/xmalloc.c Sat Feb 22 11:06:48 2014 (r262334) @@ -73,10 +73,8 @@ malloc_aligned(size_t size, size_t align { void *mem, *res; - if (align & (sizeof(void *) -1)) { - rtld_fdputstr(STDERR_FILENO, "Invalid alignment\n"); - _exit(1); - } + if (align < sizeof(void *)) + align = sizeof(void *); mem = xmalloc(size + sizeof(void *) + align - 1); res = (void *)round((uintptr_t)mem + sizeof(void *), align);