1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

16114 commits

Author SHA1 Message Date
Ludovic Courtès
556d35af88 tests: Don't rely on $TMPDIR and /tmp on Windows.
* test-suite/standalone/test-unwind.c (check_ports)[__MINGW32__]: Use
  $TEMP, $TMP, or / as the value for TMPDIR.
  Patch by Eli Zaretskii <eliz@gnu.org>.
2013-06-16 16:42:01 +02:00
Ludovic Courtès
b518c6a0b3 tests: Use double quotes around shell arguments, for Windows.
* test-suite/standalone/test-system-cmds (test-system-cmd): Use double
  quotes around shell arguments.
  Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16 16:39:14 +02:00
Ludovic Courtès
dba6f4e2e3 Define `AF_UNIX' only when Unix-domain sockets are supported.
* libguile/socket.c (scm_init_socket): Defined `AF_UNIX' only when
  `HAVE_UNIX_DOMAIN_SOCKETS' is defined.
  Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16 16:20:03 +02:00
Andy Wingo
e6450062a1 Reduce call-with-values to let for singly-valued producers
* module/language/tree-il/peval.scm (singly-valued-expression?): Add
  support for conditionals.  In the future we should add more
  expressions here.
  (peval): Don't inline values into the body of a dynwind, as that could
  cause the consumer to run in the wrong dynamic context.
  If the producer is singly-valued and the consumer just has a rest arg,
  reduce to "let" and cons up a list in the consumer.  This may reduce
  further.

* test-suite/tests/peval.test ("partial evaluation"): Add a test.
2013-06-16 15:02:34 +02:00
Andy Wingo
b34b66b346 Rewrite make-tree-il-folder to use the Wright matcher.
* module/language/tree-il.scm (make-tree-il-folder): Rewrite to use the
  Wright matcher instead of record-case.
2013-06-10 22:46:08 +02:00
Andy Wingo
98f778ea28 Rewrite unparse-tree-il to use the Wright matcher.
* module/language/tree-il.scm (unparse-tree-il): Rewrite to use the
  Wright matcher.
2013-06-10 22:46:08 +02:00
Andy Wingo
f852e05ee8 Rewrite parse-tree-il to use the Wright matcher.
* module/language/tree-il.scm (parse-tree-il): Rewrite to use match
  instead of pmatch.  Remove pmatch import.
2013-06-10 22:46:08 +02:00
Andy Wingo
007f671afc Implement tree-il-fold in terms of make-tree-il-folder.
* module/language/tree-il.scm (tree-il-fold): Implement using
  make-tree-il-folder.  This is an incompatible change: there is no more
  "leaf" procedure, and tree-il-fold only works on tree-il and not
  lists.

* module/language/tree-il/analyze.scm (<tree-analysis>, analyze-tree):
  Adapt to tree-il-fold change, losing the "leaf" handler.
  (unused-variable-analysis, unused-toplevel-analysis)
  (unbound-variable-analysis, arity-analysis): Adapt to tree-analysis
  change.

* module/language/tree-il/canonicalize.scm (tree-il-any)
* module/language/tree-il/cse.scm (build-assigned-var-table)
* module/language/tree-il/peval.scm (tree-il-any, build-var-table)
  (peval): Adapt to tree-il-fold change.

* test-suite/tests/tree-il.test ("tree-il-fold"): Adapt tests for new
  interface and expectations.
2013-06-10 22:46:08 +02:00
Andy Wingo
99b4da8fb2 Rewrite tree-il pre-post-order in terms of (ice-9 match)
* module/language/tree-il.scm (pre-post-order): Re-implement in terms
  of (ice-9 match), so that we standardize on one matcher (more or
  less).
2013-06-10 22:46:08 +02:00
Andy Wingo
25450a0d0e Pre-order tree-il rewrites are now non-destructive
* module/language/tree-il.scm (pre-order): Re-implement in terms of
  pre-post-order, and rename from pre-order!.

* module/language/tree-il/primitives.scm (expand-primitives): Adapt to
  pre-order change, and rename from expand-primitives!.

* module/language/tree-il/optimize.scm (optimize): Adapt to
  expand-primitives! change, and rename from optimize!.

* module/language/tree-il/compile-glil.scm:
* module/system/repl/common.scm:
* test-suite/tests/cse.test:
* test-suite/tests/peval.test:
* test-suite/tests/tree-il.test: Adapt to expand-primitives and optimize
  changes.
2013-06-10 22:46:08 +02:00
Andy Wingo
403d78f915 Tree-il post-order rewriter no longer destructive
* module/language/tree-il.scm (pre-post-order): New helper, like
  pre-order! and post-order! but not destructive.
  (post-order): Implement in terms of pre-post-order, and rename from
  post-order!.

* module/ice-9/compile-psyntax.scm (squeeze-tree-il):
* module/language/tree-il/canonicalize.scm (canonicalize):
* module/language/tree-il/fix-letrec.scm (fix-letrec):
* module/language/tree-il/primitives.scm (resolve-primitives): Use
  post-order, and rename from the destructive
  variants (squeeze-tree-il!, canonicalize!, etc).  Adapt callers.

* test-suite/tests/tree-il.test (strip-source): Adapt to post-order.

* test-suite/tests/cse.test:
* test-suite/tests/peval.test:
* module/language/tree-il/optimize.scm: Adapt callers.
2013-06-10 22:46:08 +02:00
Andy Wingo
64fc50c294 Simplify let-values to let if consumer binds only one variable
* module/language/tree-il/peval.scm (peval): let-values with a consumer
  that has only one argument is the same as let.

* test-suite/tests/peval.test ("partial evaluation"): Add test.
2013-06-10 22:43:13 +02:00
Andy Wingo
4828538940 fix linker.test
* test-suite/tests/linker.test (link-elf-with-one-main-section): Fix
  test after string table change.
2013-06-10 22:42:46 +02:00
Mark H Weaver
2a1d8403c0 Allow #f as timeout argument to unlock-mutex and SRFI-18 mutex-unlock!
Reported by Chaos Eternal <chaoseternal@shlug.org>
Based on a patch by Nala Ginrut <nalaginrut@gmail.com>

* libguile/threads.c (scm_unlock_mutex_timed): If 'timeout' argument
  is false, interpret that as no timeout.

* doc/ref/api-scheduling.texi (Mutexes and Condition Variables):
  Update documentation.
2013-06-10 02:34:21 -04:00
Mark H Weaver
8b12a34c8f Fix tests for 'scm_c_bind_keyword_arguments'.
* test-suite/standalone/test-scm-c-bind-keyword-arguments.c (error_handler):
  Remove function.
  (unrecognized_keyword_error_handler, invalid_keyword_error_handler,
  odd_length_error_handler): New functions.
  (test_scm_c_bind_keyword_arguments): Use new error handler functions.
2013-06-10 02:29:05 -04:00
Andy Wingo
c4c098e355 procedure-properties for RTL functions
* module/system/vm/assembler.scm (link-procprops, link-objects): Arrange
  to write procedure property links out to a separate section.

* libguile/procprop.c (scm_procedure_properties):
* libguile/programs.h:
* libguile/programs.c (scm_i_rtl_program_properties):
* module/system/vm/debug.scm (find-program-properties): Wire up
  procedure-properties for RTL procedures.  Yeah!  Fistpumps!  :)

* module/system/vm/debug.scm (find-program-debug-info): Return #f if the
  string is "", as it is if we don't have a name.  Perhaps
  elf-symbol-name should return #f in that case...

* test-suite/tests/rtl.test: Add some tests.
2013-06-09 23:59:19 +02:00
Andy Wingo
bf8328ec16 procedure-documentation works on RTL procedures
* libguile/procprop.h:
* libguile/procprop.c (scm_procedure_documentation): Move here from
  procs.c, and to make the logic more similar to that of procedure-name,
  which allows RTL programs to dispatch to rtl-program-documentation.

* libguile/programs.c (scm_i_rtl_program_documentation):
* libguile/programs.h:
* module/system/vm/program.scm (rtl-program-documentation): New
  plumbing.

* module/system/vm/debug.scm (find-program-docstring): New interface to
  grovel ELF for a docstring.
2013-06-09 23:59:01 +02:00
Andy Wingo
9128b1a19f Write docstrings into RTL ELF images
* module/system/vm/assembler.scm (link-docstrs): Write docstrings.
  (link-objects): Link docstrings into the ELF.
2013-06-09 23:48:39 +02:00
Andy Wingo
eb2bc00fb3 Wire up ability to print RTL program arities
* libguile/procprop.c (scm_i_procedure_arity): Allow RTL programs to
  dispatch to scm_i_program_arity.

* libguile/programs.c (scm_i_program_print): Refactor reference to
  write-program.
  (scm_i_rtl_program_minimum_arity): New procedure, dispatches to
  Scheme.
  (scm_i_program_arity): Dispatch to scm_i_rtl_program_minimum_arity if
  appropriate.

* module/system/vm/debug.scm (program-minimum-arity): New export.

* module/system/vm/program.scm (rtl-program-minimum-arity): New internal
  function.
  (program-arguments-alists): New helper, implemented also for RTL
  procedures.
  (write-program): Refactor a bit, and call program-arguments-alists.

* test-suite/tests/rtl.test ("simply procedure arity"): Add tests that
  arities make it all the way to cold ELF and back to warm Guile.
2013-06-09 23:43:25 +02:00
Andy Wingo
f88e574d58 (system vm debug) can read arity information
* module/system/vm/debug.scm (<arity>): New object, for reading
  arities.  Unlike <arity> in the assembler, this one only holds on to a
  couple of pointers, and doesn't even load in argument names.  Unlike
  the arity lists in (system vm program), it can load in names.  Very
  early days but it does seem to work.
  (find-program-arities, arity-arguments-alist): New higher-level
  interfaces.
2013-06-09 23:43:18 +02:00
Andy Wingo
b2006c19af RTL assembler writes arities information into separate section.
* module/system/vm/assembler.scm: Write arities into a .guile.arities
  section and associated .guile.arities.strtab.
2013-06-09 23:42:52 +02:00
Andy Wingo
3185c9071c Beginnings of tracking of procedure arities in assembler
* module/system/vm/assembler.scm (<meta>, <arity>): Assembler now tracks
  arities of a function.
  (begin-standard-arity, begin-opt-arity, begin-kw-arity, end-arity):
  New macro-assemblers.

* test-suite/tests/rtl.test: Adapt all tests to use begin-standard-arity
  and end-arity.
2013-06-09 23:37:46 +02:00
Andy Wingo
07c052796d add procedure prelude macro-instructions
* module/system/vm/assembler.scm (pack-flags): New helper.
  (standard-prelude, opt-prelude, kw-prelude): New macro-instructions.

* test-suite/tests/rtl.test: Update tests to use standard-prelude.
2013-06-09 23:36:46 +02:00
Andy Wingo
2a4daafd30 begin-program takes properties alist
* module/system/vm/assembler.scm (assert-match): New helper macro to
  check argument types.
  (<meta>): Add properties field.  Rename name field to "label" to
  indicate that it should be unique.
  (make-meta, meta-name): New helpers.
  (begin-program): Take additional properties argument.
  (emit-init-constants): Adapt to begin-program change.
  (link-symtab): Allow for anonymous procedures.

* test-suite/tests/rtl.test: Adapt tests.
2013-06-09 23:36:45 +02:00
Andy Wingo
82e299f386 Add RTL disassembler
* module/Makefile.am:
* module/system/vm/disassembler.scm: New module.

* module/system/repl/command.scm (disassemble): Work with RTL programs.
2013-06-09 20:07:57 +02:00
Andy Wingo
e65f80af42 RTL programs print with their name
* libguile/print.c (iprin1): Use scm_i_program_print for RTL programs
  too.

* libguile/procprop.c (scm_procedure_name): For RTL programs, call
  scm_i_rtl_program_name if there is no override.

* libguile/programs.h:
* libguile/programs.c (scm_i_rtl_program_name): New helper, dispatches
  to (system vm program).
  (scm_i_program_print): For RTL programs, the fallback prints the code
  pointer too.

* module/system/vm/program.scm (rtl-program-name): Use the debug info to
  get an RTL program name.
  (write-program): Work with RTL programs too.

* test-suite/tests/rtl.test ("procedure name"): Add test.
2013-06-09 19:52:10 +02:00
Andy Wingo
e2cbf527c4 move procedure-name and procedure-source to procprop.c
* libguile/procprop.h:
* libguile/procprop.c (scm_procedure_name, scm_procedure_source): Move
  these functions here, from debug.[ch].
2013-06-09 19:50:33 +02:00
Andy Wingo
cb86cbd71d Add runtime support for reading debug information from ELF
* module/Makefile.am:
* module/system/vm/debug.scm: New module.

* module/system/vm/elf.scm (elf-section-by-name): New helper.
  (elf-symbol-table-len): New helper.

* test-suite/tests/rtl.test: Add test for finding debug info.
2013-06-09 19:50:30 +02:00
Andy Wingo
e78991aa36 Add RTL assembler
* module/Makefile.am:
* module/system/vm/assembler.scm: New module, implementing an assembler
  for RTL.

* test-suite/Makefile.am:
* test-suite/tests/rtl.test: New test suite.

* module/system/vm/elf.scm (make-elf-symbol*): Add constructor; export
  as make-elf-symbol.
  (elf-symbol-len): New export.
  (write-elf32-symbol, write-elf64-symbol): New helpers.
  (write-elf-symbol): New export.
2013-06-09 17:28:25 +02:00
Andy Wingo
f5473fbaaf linker string tables are stateful objects
* module/system/vm/linker.scm (make-string-table): Rework to be a
  stateful object instead of a function object.  Works better in this
  case.  Adapt users.
  (string-table-intern!): Rename from string-table-intern, and just
  return the index of the string.
  (link-string-table!): Rename from link-string-table, and set a flag to
  prevent interning strings after linking, as that's not going to work
  well.

* module/language/objcode/elf.scm (bytecode->elf): Adapt.
2013-06-09 16:04:12 +02:00
Andy Wingo
90a7976eb8 const cleanups in instructions.c
* libguile/instructions.c (fetch_rtl_instruction_table)
  (fetch_instruction_table): Make the returned table const.  Adapt
  callers.
  (scm_rtl_instruction_list): Fix comment about format of return value.
2013-06-08 14:58:25 +02:00
Ludovic Courtès
79a9a2c271 Report the faulty keyword in errors raised by `scm_c_bind_keyword_arguments'.
Reported by Mark H. Weaver.

* libguile/keywords.c (scm_c_bind_keyword_arguments): Use
  `scm_error_scm' instead of `scm_error'.  Pass the faulty keyword
  enclosed in a list as the last argument.
* test-suite/tests/optargs.test ("scm_c_bind_keyword_arguments"): New
  test prefix.
2013-06-05 00:25:39 +02:00
Ludovic Courtès
4af0d97ee6 Print the faulty object upon invalid-keyword errors.
* libguile/vm.c (vm_error_kwargs_invalid_keyword,
  vm_error_kwargs_unrecognized_keyword): Add parameter.  Pass it
  enclosed in a list as the last argument to `scm_error_scm'.
* libguile/vm-i-system.c (bind_kwargs): Adjust accordingly.
* libguile/eval.c (error_invalid_keyword, error_unrecognized_keyword):
  Add parameter.
  (prepare_boot_closure_env_for_apply): Adjust accordingly.
* module/ice-9/eval.scm (primitive-eval): Likewise.
* libguile/error.c (scm_error_scm): Mention `keyword-argument-error' in
  docstring.
* module/ice-9/boot-9.scm (keyword-error-printer): New procedure; use it.
* test-suite/tests/optargs.test (c&e, with-test-prefix/c&e): Remove.
  ("define*")["unrecognized keyword"]: Test the value passed along the
  `keyword-argument-error' exception.
  ["invalid keyword"]: New test.
* doc/ref/api-control.texi (Error Reporting): Update `scm-error'
  description.
2013-06-04 12:08:02 +02:00
Andy Wingo
510ca12687 add new rtl vm
* libguile/vm-engine.c (rtl_vm_engine): Add new VM.
  (vm_engine): Add support for calling RTL programs.

* libguile/tags.h (scm_tc7_rtl_program): New type for procedures that
  run on the new VM.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of):
* libguile/print.c (iprin1):
* libguile/procprop.c (scm_i_procedure_arity):
* libguile/procs.c (scm_procedure_p): Add hooks for the new tc7.

* libguile/programs.h:
* libguile/programs.c (scm_make_rtl_program, scm_i_rtl_program_print)
  (scm_rtl_program_p, scm_rtl_program_code):
* module/system/vm/program.scm: Add constructors and accessors for the
  new "RTL programs".

* libguile/vm.c (rtl_boot_continuation): Define a boot program.
  (rtl_apply, rtl_values): New static RTL programs.

* libguile/frames.c (scm_frame_num_locals): Adapt for frames of RTL
  programs.

* libguile/frames.h: Add description of RTL frames.

* libguile/Makefile.am: Add rules to generate vm-operations.h.
* .gitignore: Ignore vm-operations.h.
* module/system/vm/instruction.scm:
* libguile/instructions.c:
* libguile/instructions.h: Use vm-operations.h to define enumerated
  values for the new RTL opcodes.  Define some helper macros to pack and
  unpack 32-bit instruction words.
  (rtl-instruction-list): New function, exported by (system vm
  instruction).

* libguile/objcodes.c: Wire up the bits needed to detect the new RTL
  bytecode and load it, as appropriate.
2013-05-31 09:48:16 -04:00
Ludovic Courtès
1701a68920 Do not assume `pthread_t' is an integer type.
Fixes <http://bugs.gnu.org/14469>.
Reported by Panicz Maciej Godek <godek.maciek@gmail.com>.

* libguile/finalizers.c (finalization_thread_is_running): New variable.
  (start_finalization_thread): Use it to determine whether
  FINALIZATION_THREAD is up and running.
  (stop_finalization_thread): Likewise.
2013-05-30 23:30:54 +02:00
Andy Wingo
b782ed0137 refactor to resolve_variable
* libguile/vm.c (resolve_variable): Slight refactor.
2013-05-27 07:14:33 +02:00
Andy Wingo
a0ec1ca116 cpp hygiene in the vm
* libguile/vm-engine.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: CPP hygiene: the code that #defines, #undefs.
  Makes things cleaner given the multiple inclusion dance we do.
2013-05-27 07:14:26 +02:00
Andy Wingo
c850a0ff4d pop-continuation abort-continuation hooks pass return vals directly
* doc/ref/api-debug.texi (VM Hooks): Update documentation.

* libguile/vm.c (vm_dispatch_hook):
* libguile/vm-engine.c:  Rework the hook machinery so that they can
  receive an arbitrary number of arguments.  The return and abort
  hooks will pass the values that they return to their continuations.
  (vm_engine): Adapt to ABORT_CONTINUATION_HOOK change.

* libguile/vm-i-system.c (return, return/values): Adapt to
  POP_CONTINUATION_HOOK change.

* module/system/vm/frame.scm (frame-return-values): Remove.  The
  pop-continuation-hook will pass the values directly.

* module/system/vm/trace.scm (print-return):
  (trace-calls-to-procedure):
  (trace-calls-in-procedure): Update to receive return values
  directly.

* module/system/vm/traps.scm (trap-in-procedure)
  (trap-in-dynamic-extent): Ignore return values.
  (trap-frame-finish, trap-calls-in-dynamic-extent)
  (trap-calls-to-procedure): Pass return values to the handlers.
2013-05-27 07:13:13 +02:00
Andy Wingo
27319ffaa9 Allow vm_engine caller to pass arguments on the stack.
* libguile/vm-engine.c (vm_engine): Allow the caller to pass arguments
  on the stack.
2013-05-27 07:12:22 +02:00
Andy Wingo
8dd6bfa7bb vm-engine: remove register assignments
* libguile/vm-engine.c: Remove the register assignments inherited from
  the 1990s.  GCC does seem to allocate reasonably on systems with
  enough registers (e.g. x86-64), and on system with too few (ia32) we
  disabled manual allocation.  Anyway this code was never tested, so
  it's better to leave the compiler to do its own thing, until proven
  otherwise.  Also in the RTL VM we don't need to allocate a register to
  the SP, because it isn't accessed as much.
2013-05-27 07:06:39 +02:00
Andy Wingo
ff3968c22d remove some configurability in vm-engine
* libguile/vm-engine.c: Remove the ability for the VM to check object
  access, free variable access, and the ip.  They were off by default.
  Since they will be different in the RTL VM, their presence is just
  making things confusing.

* libguile/vm.c: Remove corresponding error helpers.
2013-05-23 14:42:25 +02:00
Andy Wingo
27c7c630a1 minor vm-engine cleanups
* libguile/vm-engine.c: Some very minor cleanups: indenting, use of
  VM_ASSERT, commenting.
2013-05-23 14:38:10 +02:00
Andy Wingo
52182d5280 remove CONS macro in VM; use scm_cons instead
* libguile/vm-engine.c (CONS): Remove.  Callers should use scm_cons
  instead, syncing registers beforehand.
  (POP_LIST): Adapt, only synchronizing once.
  (POP_LIST_MARK, POP_CONS_MARK): Remove unused macros.

* libguile/vm-i-scheme.c (cons):
* libguile/vm-i-system.c (push-rest, bind-rest): Adapt.
2013-05-23 14:27:17 +02:00
Andy Wingo
eac1202483 inline vm-engine.h into vm-engine.c
* libguile/vm-engine.h:
* libguile/vm-engine.c: Fold vm-engine.h into vm-engine.c.

* libguile/Makefile.am: Adapt.
2013-05-23 14:27:17 +02:00
Andy Wingo
fb9600debc add (find-mapped-elf-image) procedure to (system vm objcode) module
* libguile/objcodes.c (register_elf, scm_find_mapped_elf_image): New
  interfaces that keep a list of all ELF mappings.  Exported from the
  (system vm objcode) module.

* module/system/vm/objcode.scm: Export find-mapped-elf-image.
2013-05-23 14:21:06 +02:00
Andy Wingo
e1aee492d7 refactor and simplify ELF loader in objcodes.c
* libguile/objcodes.c (sniff_elf_alignment, alloc_aligned)
  (copy_and_align_elf_data): New helpers for portably re-aligning ELF
  data from read(2) or from a bytevector.
  (load_thunk_from_memory): Simplify!  Now there is only one procedure
  that loads ELF, and it does less: it simply receives the whole image
  in one array, hopefully from mmap.

  (scm_load_thunk_from_file): Use new map_file_contents helper, and go
  through load_thunk_from_memory.
  (scm_load_thunk_from_memory): Pass load_thunk_from_memory a piece of
  memory that it owns, and that is appropriately aligned.
2013-05-23 14:19:06 +02:00
Andy Wingo
0b3b73698c add scm_{to,from}_{u,}intptr_t
* libguile/numbers.h (scm_to_intptr_t, scm_from_intptr_t)
  (scm_to_uintptr_t, scm_from_uintptr_t): New defines.

* libguile/foreign.c: Remove definitions here; adapt callers to use new
  names with _t suffixes.
2013-05-23 14:19:06 +02:00
Andy Wingo
d4da9ba9c0 refactor linker to lay out ELF files and memory in the same way
* 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.

  (relocate-section-header, allocate-segment): 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.

  (link-elf): Refactor to use the new interfaces.

* test-suite/tests/linker.test: Update to expect the additional sections
  for the header and section table.
2013-05-23 12:44:02 +02:00
Andy Wingo
51611a92f4 elf: add accessors for header members that might need relocation
* module/system/vm/elf.scm (elf-header-shoff-offset)
  (elf-section-header-addr-offset, elf-section-header-offset-offset):
  New accessors.
2013-05-23 11:02:14 +02:00
Andy Wingo
6756d265ed 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.
2013-05-23 11:02:02 +02:00