From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 5/6] refactor and simplify ELF loader in objcodes.c Date: Thu, 23 May 2013 12:58:29 +0200 Message-ID: <8761ya3qui.fsf@pobox.com> References: <1368889540-27139-1-git-send-email-wingo@pobox.com> <1368889540-27139-6-git-send-email-wingo@pobox.com> <87a9nm7mho.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369306721 10184 80.91.229.3 (23 May 2013 10:58:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 May 2013 10:58:41 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu May 23 12:58:41 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UfTEG-0007GV-BV for guile-devel@m.gmane.org; Thu, 23 May 2013 12:58:40 +0200 Original-Received: from localhost ([::1]:50701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfTEG-0007CY-2W for guile-devel@m.gmane.org; Thu, 23 May 2013 06:58:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfTEB-0007CT-I7 for guile-devel@gnu.org; Thu, 23 May 2013 06:58:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfTE9-0007xc-HG for guile-devel@gnu.org; Thu, 23 May 2013 06:58:35 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:38235 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfTE9-0007xY-DQ; Thu, 23 May 2013 06:58:33 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 01904DD64; Thu, 23 May 2013 06:58:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=HUBktnilM/oj md9Q5zbSjQxnIyw=; b=kqQ7lKbVlf8/i0lui213c9NthgHF+JQAVBNHvROAPCyW CxZLJqY0lxXTGNowT6iCLxHk4aE8l9b+T1Hk3F+40FojE4Mxj/BqgXgZXtqJutj4 46Z0Zlk4mlMV8gJrmnTUyTUmPNmHB/FOvfa8n7V1yf5EqBqbMSE3oPl8oYWf3Es= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=TYKrvO OhDtsZ+sb+uNZ9ACuw0xhWTeDSDRz0jzZc9aqc73BCTTHFX8KsnQFqwjLfh9y6fM NxOE9oneDsgyxRTpDlvmcc9G9coWRffQx5OBwGRERTzs1r0eHrGpUFqgB7ATXV64 5Y1VG4kflheL65wNZidIuLOCcA4fzEM9F3yts= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id EA64BDD63; Thu, 23 May 2013 06:58:32 -0400 (EDT) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 39725DD62; Thu, 23 May 2013 06:58:32 -0400 (EDT) In-Reply-To: <87a9nm7mho.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Wed, 22 May 2013 23:06:43 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-Pobox-Relay-ID: B54AD0A4-C397-11E2-ABE0-9F710E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16423 Archived-At: On Wed 22 May 2013 23:06, ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> +/* This function leaks the memory that it allocates. */ >> +static char* >> +alloc_aligned (size_t len, unsigned alignment) > > What about using posix_memalign or similar? Not present on many systems, and gnulib can't make a useful wrapper. If you do the normal trick of allocating more with malloc then aligning it, you make it impossible to free(). > Alternatively, using scm_gc_malloc_pointerless, which is known to return > 8-byte-aligned boundary? For two reasons. One is that this memory is not collectable. Static allocation of constants means that you can get pointers into the middle of the image from the heap. I wanted to avoid pressuring the GC. The other reason is that you can get pointers out of the image *to* the heap -- for data that is statically allocated, but fixed up at runtime. For example, keywords. Their stringbuf is allocated statically in read-only memory, but there is also a cell allocated for the keyword itself, and that lives on the heap. The best is to use mmap. But if you fall back, malloc is OK, and we can manually align it. In any case the loader ends up adding part of the image to the GC roots, so it's probably best that the memory not be managed by the GC itself. >> + /* If our optimism failed, fall back. */ >> + { >> + unsigned alignment =3D sniff_elf_alignment (data, end); >> + >> + if (alignment !=3D 8) > > Since .go are only produced by Guile, can it really happen to have .go > files without 8-byte alignment? Yes! If the system supports mmap, .go files should be produced with 4096-byte alignment so that the whole thing can be mapped read-only, and write permissions only need be given to the writable pages. (Mprotect only works on a page level.) Cheers, Andy --=20 http://wingolog.org/