Re: [PATCH 4/6] refactor linker to lay out ELF files and memory in the same way

2013-05-23 Thread Ludovic Courtès
Andy Wingo wi...@pobox.com skribis:

 On Wed 22 May 2013 22:56, l...@gnu.org (Ludovic Courtès) writes:

 Please move the descriptions as docstrings.

 Done.  I've added docstrings for this file in the patch that I'll push,
 and taken the opportunity to simplify some other things.  Attaching a
 copy of the linker; it's easier to read as a file than as a patch.

Very nice, thank you!

I think it’ll make it easier for people to page it in.  ;-)

Ludo’.



Re: [PATCH 4/6] refactor linker to lay out ELF files and memory in the same way

2013-05-22 Thread Ludovic Courtès
This goes beyond my ELF capabilities, so can’t really comment on this.

Style comments:

Andy Wingo wi...@pobox.com skribis:

 * module/system/vm/linker.scm (make-linker-object):
   (linker-object-section-symbol):
   (linker-object-symbols*): Create a symbol to the start of a linker
   object.  Hide it from the external linker-object-symbols* accessor.

   (segment-kind, count-segments): Sections without SHF_ALLOC don't get
   segments.
   (collate-objects-into-segments): Allow for #f segment types.  If two
   sections have the same type and flags, leave them in the same order.

   (align): Allow for 0 alignment.

   (add-elf-objects): New helper: puts the ELF data structures (header,
   segment table, and section table) in sections of their own.  This
   lends a nice clarity and conceptual unity to the linker.

Please move the descriptions as docstrings.

   (relocate-section-header, alloc-objects): Lay out segments with
   congruent, contiguous addresses, so that we can just mmap the file and
   if debugging sections that are not in segments are present, they can
   be lazily paged in if needed by the kernel's VM system.

Nice.  Could you move this comment in the code?

  ;; objects ::= list of linker-object
 -;; = 3 values: ELF header, program headers, objects
 +;;
 +;; = 3 values:
 +;;   file size
 +;;   objects with allocated memory address and file offset
 +;;   symbol table
 +;;
  (define (allocate-elf objects page-aligned? endianness word-size)

What does it do?

Ludo’.