ELF refactor and consequent linker simplifications
authorAndy Wingo <wingo@pobox.com>
Sun, 21 Apr 2013 14:06:36 +0000 (16:06 +0200)
committerAndy Wingo <wingo@pobox.com>
Thu, 23 May 2013 09:02:02 +0000 (11:02 +0200)
commit6756d265ed53d7b107d31746e8455f10e2ecebdd
tree098cc14e9ff6f481e3d0ccad6a929faa310bbc8e
parent45037e75277b622334f347ef261ea347eec6e28d
ELF refactor and consequent linker simplifications

* module/system/vm/elf.scm: Add commentary.
  (make-elf): Add a constructor similar to make-elf-segment and
  make-elf-section.
  (write-elf32-header, write-elf64-header, write-elf-header): Take an
  <elf> instead of all the fields separately.
  (<elf-segment>, <elf-section>): Add "index" property.  Adapt
  constructors accordingly.

* module/language/objcode/elf.scm (bytecode->elf): Arrange to set the
  section indexes when creating ELF sections.

* module/system/vm/linker.scm (fold-values): New helper.
  (alloc-segment, relocate-section-header): Arrange to set segment and
  section indexes.
  (find-shstrndx): New helper, replaces compute-sections-by-name.  Now
  that sections know their indexes, this is easier.
  (allocate-elf, write-elf): New helpers, factored out of link-elf.
  Easier now that sections have indexes.
  (link-elf): Simplify.  Check that the incoming objects have sensible
  numbers.

* test-suite/tests/linker.test: Update to set #:index on the linker
  objects.
module/language/objcode/elf.scm
module/system/vm/elf.scm
module/system/vm/linker.scm
test-suite/tests/linker.test