guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/6] refactor and simplify ELF loader in objcodes.c


From: Ludovic Courtès
Subject: Re: [PATCH 5/6] refactor and simplify ELF loader in objcodes.c
Date: Fri, 24 May 2013 17:37:47 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Andy Wingo <address@hidden> skribis:

> On Thu 23 May 2013 22:35, address@hidden (Ludovic Courtès) writes:
>
>>> 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.
>>
>> But malloc’d and mmap’d regions are not scanned by default, so here they
>> would need to be scanned, or the GC-managed data they refer to would
>> need to be registered as root, no?
>>
>> (This reminds me of
>> <http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2576>,
>> except that with Guile’s loader GNU_RELRO regions could refer to
>> GC-managed data.)
>
> See the patch :)  There is a part of the dynamic section that specifies
> the GC roots, which are added using GC_add_roots.

Oh, great.

>>>> 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.)
>>
>> Oh, I’m lost.  Is it 8B or 4KiB?  Can’t .go files always be
>> page-aligned?
>
> In 2.0 the alignment is 8 bytes.  In 2.2, it can be any multiple of 8
> bytes -- including 4096.
>
> From linker.scm:
>
>     ;;; By default, the ELF files created by the linker include some padding
>     ;;; so that different parts of the file can be loaded in with different
>     ;;; permissions.  For example, some parts of the file are read-only and
>     ;;; thus can be shared between processes.  Some parts of the file don't
>     ;;; need to be loaded at all.  However this padding can be too much for
>     ;;; interactive compilation, when the code is never written out to disk;
>     ;;; in that case, pass #:page-aligned? #f to `link-elf'.
>
> And:
>
>     If @var{page-aligned?} is true, read-only and writable data are
>     separated so that only those writable parts of the image need be mapped
>     with writable permissions.  This is suitable for situations where you
>     would write a file out to disk and read it in with @code{mmap}.
>     Otherwise if @var{page-aligned?} is false, sections default to 8-byte
>     alignment.

OK, I understand now.  Thanks for the pointers!

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]