[RFC] Encoding of modes in module exports

Jose E. Marchesi jemarch@gnu.org
Mon Nov 3 22:04:23 GMT 2025


Hello people.

Some notes for your consideration.

Exports for modules will encompass all the PUBlicized declarations of a
module.

The export data will always be embedded in an ELF file, be it
accompanying the compiled code for a compilation unit (foo.o, foo.so) or
standalone (foo.m68), in the later case the only sections in the file
will be the string table and the exports section.

The export data will be stored in a section .ga68_exports.
The .ga68_exports section contents shall be concatenable.

Since we are in ELF, we can and should use the file's string table for
indicators of modes, etc.

We can use section-relative data relocations to refer to contents of
.ga68_exports from within .ga68_exports.

We can use section-relative text relocations to refer to functions for
things like row bounds.

Below is a sketch of the definition for the encoding of modes.
Comments?

---

load elf;

type ga68_str = offset<Elf_Word,B>;
type ga68_text_reloc = Elf64_Addr;
type ga68_data_reloc = Elf64_Addr;

var GA68_MODE_VOID = 0,
    GA68_MODE_INT = 1,
    GA68_MODE_REAL = 2,
    GA68_MODE_CHAR = 3,
    GA68_MODE_CMPL = 4,
    GA68_MODE_ROW = 5,
    GA68_MODE_STRUCT = 6,
    GA68_MODE_UNION = 7,
    GA68_MOID = 8;

type ga68_mode =
  struct
  {
    Elf_Word kind;
    union
    {
      struct
      {
        ga68_text_reloc name;
        ga68_data_reloc mode;
      } moid : kind == GA68_MODE_MOID;

      struct
      {
        Elf_Word dim;
        struct { ga68_text_reloc lb; ga68_text_reloc ub; uint<64> stride; }[dim] triplets;
        ga68_data_reloc row_of;
      } row : kind == GA68_MODE_ROW;

      struct
      {
        Elf_Word nfields;
        struct { ga68_str name; ga68_data_reloc mode }[nfields] fields;
      } sct : kind == GA68_MODE_STRUCT;

      struct
      {
        Elf_Word nmodes;
        ga68_data_reloc[nmodes] modes;
      } uni : kind == GA68_MODE_UNION;

      struct {};
    } data;
  };


More information about the Algol68 mailing list