Replace definition.h with definition_dcls.[ch], can now walk definitions list
authorNick Downing <nick@ndcode.org>
Sat, 12 Oct 2019 22:36:52 +0000 (09:36 +1100)
committerNick Downing <nick@ndcode.org>
Sat, 12 Oct 2019 23:16:09 +0000 (10:16 +1100)
Makefile
definition.h [deleted file]
definition_dcls.c [new file with mode: 0644]
definition_dcls.h [new file with mode: 0644]
multics_sim.c
object_map.h
pl1/definition.incl.pl1 [deleted file]

index b3d2dcc..c495fbe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@ CFLAGS=-g -O3 -std=c99 -U__STRICT_ANSI__ -IdecNumber -Idps8 -D_GNU_SOURCE -DUSE_
 
 multics_sim: \
 multics_sim.o \
+definition_dcls.o \
 decNumber/decContext.o \
 decNumber/decDouble.o \
 decNumber/decimal128.o \
@@ -27,7 +28,8 @@ dps8/dps8_utils.o \
 dps8/hdbg.o
        ${CC} ${CFLAGS} -o $@ $^ -lm
 
-multics_sim.o: multics_sim.c definition.h object_map.h rassert.h
+multics_sim.o: multics_sim.c definition_dcls.h object_map.h rassert.h
+definition_dcls.o: definition_dcls.c definition_dcls.h
 decNumber/decContext.o: decNumber/decContext.c
 decNumber/decDouble.o: decNumber/decDouble.c
 decNumber/decimal128.o: decNumber/decimal128.c
diff --git a/definition.h b/definition.h
deleted file mode 100644 (file)
index b6906e6..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef _DEFINITION_H
-#define _DEFINITION_H 1
-
-// see definition.incl.pl1
-
-// dcl 1 definition    aligned based,
-struct definition {
-  // 2 forward unal bit(18),   /* offset of next def */
-  // 2 backward unal bit(18),  /* offset of previous def */
-  uint64_t backward : 18;
-  uint64_t forward : 18;
-  uint64_t dummy0 : 28;
-
-  // 2 value unal bit(18),
-  // 2 flags unal,
-  //   3 new bit(1),
-  //   3 ignore bit(1),
-  //   3 entry bit(1),
-  //   3 retain bit(1),
-  //   3 argcount bit(1),
-  //   3 descriptors bit(1),
-  //   3 indirect bit(1),
-  //   3 unused bit(8),
-  // 2 class unal bit(3),
-  uint64_t class : 3;
-  uint64_t flags_unused : 8;
-  uint64_t flags_indirect : 1;
-  uint64_t flags_descriptors : 1;
-  uint64_t flags_argcount : 1;
-  uint64_t flags_retain : 1;
-  uint64_t flags_entry : 1;
-  uint64_t flags_ignore : 1;
-  uint64_t flags_new : 1;
-  uint64_t value : 18;
-  uint64_t dummy1 : 28;
-
-  // 2 symbol unal bit(18),    /* offset of ACC for symbol */
-  // 2 segname unal bit(18);   /* offset of segname def */
-  uint64_t segname : 18;
-  uint64_t symbol : 18;
-};
-
-#endif
diff --git a/definition_dcls.c b/definition_dcls.c
new file mode 100644 (file)
index 0000000..58a44fd
--- /dev/null
@@ -0,0 +1,30 @@
+#include "definition_dcls.h"
+
+char *class_names[7] = {
+  "text",
+  "linkage",
+  "symbol",
+  "segname",
+  "static",
+  "system",
+  "heap"
+};
+
+char *symbolic_section_names[7] = {
+  "*text",
+  "*link",
+  "*symbol",
+  "*",
+  "*static",
+  "*system",
+  "*heap"
+};
+
+char *link_type_names[6] = {
+  "absolute in section",
+  "unused",
+  "absolute off of refname",
+  "symbolic off of refname",
+  "symbolic in section",
+  "symbolic off of refname; create"
+};
diff --git a/definition_dcls.h b/definition_dcls.h
new file mode 100644 (file)
index 0000000..463f51d
--- /dev/null
@@ -0,0 +1,522 @@
+#ifndef _DEFINITION_DCLS_H
+#define _DEFINITION_DCLS_H
+
+#include <stdint.h>
+
+// see pl1/definition_dcls.incl.pl1
+
+/* everything for the definition section */
+
+// declare (
+enum {
+ // CLASS_TEXT init (0), /* text section definition */
+ CLASS_TEXT = 0,
+ // CLASS_LINKAGE init (1), /* linkage section definition */
+ CLASS_LINKAGE = 1,
+ // CLASS_SYMBOL init (2), /* symbol section definition */
+ CLASS_SYMBOL = 2,
+ // CLASS_SEGNAME init (3), /* segment name definition */
+ CLASS_SEGNAME = 3,
+ // CLASS_STATIC init (4), /* static section definition */
+ CLASS_STATIC = 4,
+ // CLASS_SYSTEM init (5), /* valid only in self links, not def class */
+ CLASS_SYSTEM = 5,
+ // CLASS_HEAP init (6) /* valid only in self links, not def class */
+ CLASS_HEAP = 6
+// ) fixed bin (3) unsigned internal static options (constant);
+};
+
+// declare CLASS_NAMES (0:6) character (12) internal static options (constant)
+// init ("text", "linkage", "symbol", "segname", "static", "system", "heap");
+extern char *class_names[7];
+
+// declare SYMBOLIC_SECTION_NAMES (0:6) character (8)
+// init ("*text", "*link", "*symbol", *, "*static", "*system", "*heap") internal static
+// options (constant);
+extern char *symbolic_section_names[7];
+
+// declare 1 definition_flags unaligned based,
+//   2 new bit (1), /* should be "1"b */
+//   2 ignore bit (1), /* cannot snap link to this */
+//   2 entry bit (1), /* can tra here */
+//   2 retain bit (1), /* binder respects this */
+//   2 argcount bit (1), /* OBSOLETE */
+//   2 descriptors bit (1), /* OBSOLETE */
+//   2 indirect bit (1), /* target is a pointer to actual target */
+//   2 unused bit (8); /* Must be zero */
+
+/* Header of the definition section */
+
+// declare def_header_ptr pointer;
+// declare 1 definition_header aligned based (def_header_ptr),
+struct definition_header {
+  // 2 def_list_relp fixed bin (18) unsigned unaligned,
+  // /* first definition, reloc def18 */
+  // 2 msf_map_relp fixed bin (18) unsigned unaligned,
+  // /* msf_map if any, or 0 if none. reloc def18 unless none */
+  uint64_t msf_map_relp : 18;
+  uint64_t def_list_relp : 18;
+  uint64_t dummy0 : 28;
+
+  // 2 hash_table_relp fixed bin (18) unsigned unaligned,
+  // /* def hash table, if any, or 0 if none. reloc def18 unless none */
+  // 2 flags unaligned like definition_flags;
+  // /* both new and ignore must be "1"b here */
+  uint64_t dummy1 : 3;
+  uint64_t flags_unused : 8;
+  uint64_t flags_indirect : 1;
+  uint64_t flags_descriptors : 1;
+  uint64_t flags_argcount : 1;
+  uint64_t flags_retain : 1;
+  uint64_t flags_entry : 1;
+  uint64_t flags_ignore : 1;
+  uint64_t flags_new : 1;
+  uint64_t hash_table_relp : 18;
+  uint64_t dummy2 : 28;
+};
+
+/* A non class=3 definition. See segname_definition below for class=3 */
+
+// declare def_ptr pointer;
+// declare 1 definition aligned based (def_ptr),
+struct definition {
+  // 2 forward_relp unal fixed bin (18) unsigned,
+  // /* offset of next def */
+  // 2 backward_relp unal fixed bin (18) unsigned,
+  // /* offset of previous def */
+  uint64_t backward_relp : 18;
+  uint64_t forward_relp : 18;
+  uint64_t dummy0 : 28;
+
+  // 2 thing_relp unal fixed bin (18) unsigned,
+  // /* offset in section specified by class of thing this defines */
+  // 2 flags unaligned like definition_flags,
+  // 2 class unal fixed bin (3) unsigned,
+  // /* Type of definition */
+  uint64_t class : 3;
+  uint64_t flags_unused : 8;
+  uint64_t flags_indirect : 1;
+  uint64_t flags_descriptors : 1;
+  uint64_t flags_argcount : 1;
+  uint64_t flags_retain : 1;
+  uint64_t flags_entry : 1;
+  uint64_t flags_ignore : 1;
+  uint64_t flags_new : 1;
+  uint64_t thing_relp : 18;
+  uint64_t dummy1 : 28;
+
+  // 2 name_relp unal fixed bin (18) unsigned,
+  // /* offset of ACC for symbol */
+  // 2 segname_relp unal fixed bin (18) unsigned;
+  // /* offset of segname def to which this belongs */
+  uint64_t segname_relp : 18;
+  uint64_t name_relp : 18;
+  uint64_t dummy2 : 28;
+};
+
+/* Class=3, segname definition */
+
+// declare segname_ptr pointer;
+// declare 1 segname_definition aligned based (segname_ptr),
+struct segname_definition {
+  // 2 forward_relp unal fixed bin (18) unsigned,
+  // /* offset of next def */
+  // 2 backward_relp unal fixed bin (18) unsigned,
+  // /* offset of previous def */
+  uint64_t backward_relp : 18;
+  uint64_t forward_relp : 18;
+  uint64_t dummy0 : 28;
+
+  // 2 next_segname_relp unal fixed bin (18) unsigned,
+  // /* offset of next segname def */
+  // 2 flags unaligned like definition_flags,
+  // 2 class unal fixed bin (3) unsigned,
+  // /* 3 for segname */
+  uint64_t class : 3;
+  uint64_t flags_unused : 8;
+  uint64_t flags_indirect : 1;
+  uint64_t flags_descriptors : 1;
+  uint64_t flags_argcount : 1;
+  uint64_t flags_retain : 1;
+  uint64_t flags_entry : 1;
+  uint64_t flags_ignore : 1;
+  uint64_t flags_new : 1;
+  uint64_t next_segname_relp : 18;
+  uint64_t dummy1 : 28;
+
+  // 2 name_relp unal fixed bin (18) unsigned,
+  // /* offset of ACC for symbol */
+  // 2 first_relp unal fixed bin (18) unsigned;
+  // /* see following : */
+  uint64_t first_relp : 18;
+  uint64_t name_relp : 18;
+  uint64_t dummy2 : 28;
+};
+
+/* Definition blocks are chained off of segname definitions.
+segname_definition.first_relp is one of three things:
+(1) the def section offset of the first ordinary (class^=3) definition
+belonging to this segname block. In the case where there are more than
+one segname's on a block, all their first_relp will point
+to the same place.
+
+(2) if there are no ordinary definitions associated with this segname,
+then it is the def section offset of the next segname. 
+
+(3) if there are no ordinary definitions in the block, and it
+is the last block, then it points to a word containing 0.
+
+Thus the end of a list of synonym segnames can be detected by forward_relp
+pointing to a class=3 definition whose first_relp is not the same as
+the current definitions first_relp.
+*/
+
+/* All the definitions are linked through the forward and
+backward thread variables. The end of the chain can is indicated
+by forward pointing to a zero word. */
+
+// declare exp_ptr pointer;
+// declare 1 exp_word based (exp_ptr) aligned, /* expression word in link definition */
+struct exp_word {
+  // 2 type_relp fixed bin (18) unsigned unal,
+  // /* pointer (rel to defs) of type pair structure */
+  // 2 expression fixed bin (17) unal; /* constant expression to be added in when snapping link */
+  int64_t expression : 18;
+  uint64_t type_relp : 18;
+  uint64_t dummy1 : 28;
+};
+
+// declare (
+enum {
+  // LINK_SELF_BASE init (1), /* *section|0+expression,modifier */
+  // /* which section determined by segname_relp */
+  LINK_SELF_BASE = 1,
+  // LINK_OBSOLETE_2 init (2), /* not used */
+  LINK_OBSOLETE = 2,
+  // LINK_REFNAME_BASE init (3), /* refname|0+expression,modifier */
+  LINK_REFNAME_BASE = 3,
+  // LINK_REFNAME_OFFSETNAME init (4), /* refname|offsetname+expression,modifier */
+  LINK_REFNAME_OFFSETNAME = 4,
+  // LINK_SELF_OFFSETNAME init (5), /* *section|offsetname+expression,modifier */
+  LINK_SELF_OFFSETNAME = 5,
+  // LINK_CREATE_IF_NOT_FOUND init (6), /* OBSOLETE: like LINK_REFNAME_OFFSETNAME except that it will create instead of taking linkage_error */
+  LINK_CREATE_IF_NOT_FOUND = 6,
+  // SECTION_TEXT init (0), /* *text */
+  SECTION_TEXT = 0,
+  // SECTION_LINK init (1), /* *link */
+  SECTION_LINK = 1,
+  // SECTION_SYMBOL init (2), /* *symbol */
+  SECTION_SYMBOL = 2,
+  // SECTION_UNUSED init (3), /* reserved */
+  SECTION_UNUSED = 3,
+  // SECTION_STATIC init (4), /* *static */
+  SECTION_STATIC = 4,
+  // SECTION_SYSTEM init (5), /* *system */
+  SECTION_SYSTEM = 5,
+  // SECTION_HEAP init (6) /* *heap */
+  SECTION_HEAP = 6
+// ) fixed bin (18) unsigned unaligned internal static options (constant);
+};
+
+/* use CLASS_NAMES for section names */
+
+// declare LINK_TYPE_NAMES (1:6)
+// init ("absolute in section", "unused", "absolute off of refname",
+// "symbolic off of refname", "symbolic in section", "symbolic off of refname; create")
+// character (32) varying internal static options (constant);
+extern char *link_type_names[6];
+
+// declare type_ptr pointer;
+// declare 1 type_pair based (type_ptr) aligned,/* type pair in link definition */
+struct type_pair {
+  // 2 type fixed bin (18) unsigned unal,
+  // /* see above */
+  // 2 trap_relp fixed bin (18) unsigned unal,
+  // /* pointer (rel to defs) to the trap word */
+  // /* unless LINK_SELF_OFFSETNAME off of *system or create link */
+  uint64_t trap_relp : 18;
+  uint64_t type : 18;
+  uint64_t dummy0 : 28;
+
+  // 2 segname_relp fixed bin (18) unsigned unal,
+  // /* pointer (rel to defs) to ACC reference name for segment referenced, 
+  // /*or section code for SELF links */
+  // 2 offsetname_relp fixed bin (18) unsigned unal;
+  // /* for OFFSETNAME links, ACC string of name of location. */
+  // /* for others, must be ZERO */
+  uint64_t offsetname_relp : 18;
+  uint64_t segname_relp : 18;
+  uint64_t dummy1 : 28;
+};
+
+/* Link Trap Pair */
+
+// declare link_trap_ptr pointer;
+// declare 1 link_trap_pair aligned based (link_trap_ptr),
+struct link_trap_pair {
+  // 2 call_relp fixed bin (18) unsigned unaligned,
+  // /* LINK18, link to thing to call */
+  // 2 info_relp fixed bin (18) unsigned unaligned;
+  // /* LINK18, link to argument list */
+  uint64_t info_relp : 18;
+  uint64_t call_relp : 18;
+  uint64_t dummy0 : 28;
+};
+
+/* initialization info for *system or *heap link */
+
+/* NOTE --------------------------------------------------
+the following structures defining initialization information are also
+defined in fortran_storage.incl.pl1 system_link_init_info.incl.pl1
+and should be kept equivalent
+-------------------------------------------------------
+*/
+
+// declare (
+enum {
+  // INIT_NO_INIT init (0),
+  INIT_NO_INIT = 0,
+  // INIT_COPY_INFO init (3),
+  INIT_COPY_INFO = 3,
+  // INIT_DEFINE_AREA init (4),
+  INIT_DEFINE_AREA = 4,
+  // INIT_LIST_TEMPLATE init (5),
+  INIT_LIST_TEMPLATE = 5,
+  // INIT_DEFERRED init (6)
+  INIT_DEFERRED = 6
+// ) fixed bin internal static options (constant);
+};
+
+/* for type = 0 or 4 */
+
+// declare link_init_ptr pointer;
+// declare 1 link_init aligned based (link_init_ptr),
+struct link_init {
+  // 2 n_words fixed bin (35), /* number to invent */
+  // 2 type fixed bin; /* see types above */
+  int64_t n_words : 36;
+  uint64_t dummy0 : 28;
+  uint64_t dummy1 : 18;
+  uint64_t type : 18;
+  uint64_t dummy2 : 28;
+};
+
+/* for type=3, there is data to copy */
+
+// declare 1 link_init_copy_info aligned based (link_init_ptr),
+struct link_init_copy_info {
+  // 2 header aligned like link_init,
+  int64_t n_words : 36;
+  uint64_t dummy0 : 28;
+  uint64_t dummy1 : 18;
+  uint64_t type : 18;
+  uint64_t dummy2 : 28;
+
+  // 2 initial_data (link_init_n_words refer (link_init_copy_info.header.n_words)) bit (36) aligned;
+  uint64_t initial_data[];
+};
+
+// declare link_init_n_words fixed bin;
+
+/* for type = 5, there is a list template to copy */
+
+/* A list template consists of a series of entries with the following
+description, concatenated together. n_bits and datum are bit items,
+to permit a wide range of inputs.
+
+1. A 'repeat' of '0' signifies skipping of 'n_bits' bits.
+2. A 'n_bits' of '0' signifies the last item of the list.
+
+COMMON, VLA's, and LA's are presumed to start at the base pointer
+of their particular storage section. */
+
+// declare 1 list_template_entry aligned based,
+struct list_template_entry {
+  // 2 n_bits fixed bin (35) aligned, /* size of datum */
+  // 2 mbz bit (3) unaligned, /* future expansion */
+  // 2 init_type fixed bin (3) unsigned unaligned, /* 0 normal init, 1 ptr init, 2 packed ptr init */
+  // 2 repeat fixed bin (30) unsigned unaligned,
+  // /* number of times to repeat datum */
+  // 2 datum bit (link_init_n_bits_in_datum refer (list_template_entry.n_bits));
+  int64_t n_bits : 36;
+  uint64_t dummy0 : 28;
+  uint64_t mbz : 3;
+  uint64_t init_type : 3;
+  uint64_t repeat0 : 24;
+  uint64_t repeat1 : 6;
+  uint64_t datum : 30;
+  uint64_t dummy1 : 28;
+};
+
+// declare 1 link_init_list_template
+// aligned based (link_init_ptr),
+struct link_init_list_template {
+  // 2 header aligned like link_init,
+  // 2 pad bit (18) unaligned,
+  int64_t n_words : 36;
+  uint64_t dummy0 : 28;
+  uint64_t pad_bit : 18;
+  uint64_t type : 18;
+  uint64_t dummy1 : 28;
+
+  // 2 n_words_in_list fixed bin (18) unsigned unaligned,
+  uint64_t dummy2 : 18;
+  uint64_t n_words_in_list : 18;
+  uint64_t dummy3 : 28;
+
+  // 2 template (link_init_n_words_in_list refer (link_init_list_template.n_words_in_list));
+  struct list_template_entry template[];
+};
+
+// declare link_init_n_words_in_list
+// fixed bin;
+
+/* the pointer_init_template represents the initialization information
+for ITS and packed pointers. Both pointer types require the entire
+72 bit structure.
+*/
+
+// dcl 1 pointer_init_template based,
+struct pointer_init {
+  // 2 ptr_type fixed bin (18) unsigned unaligned, /* 0 text section, 1 linkage section, 2 static section */
+  // 2 section_offset fixed bin (18) unsigned unaligned, /* offset to item in specified section */
+  uint64_t section_offset : 18;
+  uint64_t ptr_type : 18;
+  uint64_t dummy0 : 28;
+
+  // 2 word_offset fixed bin (18) unsigned unaligned, /* offset from section item to target in words */
+  // 2 mbz bit (12) unaligned,
+  // 2 bit_offset fixed bin (6) unsigned unaligned; /* offset from section item|word offset to target in bits */
+  uint64_t bit_offset : 6;
+  uint64_t mbz : 12;
+  uint64_t word_offset : 18;
+  uint64_t dummy1 : 28;
+};
+
+// declare link_init_n_bits_in_datum
+// fixed bin (35);
+
+/* for type = 6, the init_info resides in another MSF component */
+/* target_relp is a linkage section offset to a partial link to */
+/* the base of the linkage section of the component containing */
+/* the actual init_info. link_relp is the offset of the actual */
+/* link within that linkage section. */
+
+// declare 1 link_init_deferred aligned based (link_init_ptr),
+struct link_init_deferred_aligned {
+  // 2 header aligned like link_init,
+  // 2 target_relp fixed bin (18) unsigned unaligned,
+  int64_t n_words : 36;
+  uint64_t dummy0 : 28;
+  uint64_t target_relp : 18;
+  uint64_t type : 18;
+  uint64_t dummy1 : 28;
+
+  // 2 link_relp fixed bin (18) unsigned unaligned;
+  uint64_t link_relp : 18;
+  uint64_t dummy2 : 46;
+};
+
+/* Definition section hash table */
+
+// declare def_ht_ptr pointer;
+// declare 1 definition_ht aligned based (def_ht_ptr),
+struct definition_ht {
+  // 2 n_entries fixed bin,
+  uint64_t dummy0 : 18;
+  int64_t n_entries : 18;
+  uint64_t dummy1 : 28;
+
+  // 2 table (def_ht_n_entries refer (definition_ht.n_entries)) aligned,
+  struct {
+    // 3 def_relp fixed bin (18) unsigned unaligned,
+    // 3 unused bit (18) unaligned;
+    uint64_t unused : 18;
+    uint64_t def_relp : 18;
+    uint64_t dummy0 : 28;
+  } table[];
+};
+
+// declare def_ht_n_entries fixed bin;
+
+// /* Component name ht */
+// declare comp_ht_ptr pointer;
+// declare 1 component_ht aligned based (comp_ht_ptr),
+struct component_ht {
+  // 2 n_entries fixed bin,
+  uint64_t dummy0 : 18;
+  int64_t n_entries : 18;
+  uint64_t dummy1 : 28;
+
+  // 2 table (comp_ht_n_entries refer (component_ht.n_entries)) aligned,
+  struct {
+    // 3 def_relp fixed bin (18) unsigned unaligned,
+    // /* hashed segname */
+    // 3 block_hdr_relp fixed bin (18) unsigned unaligned;
+    // /* first segname def of block containing def_relp */
+    uint64_t block_hdr_relp : 18;
+    uint64_t def_relp : 18;
+    uint64_t dummy0 : 28;
+  } table[];
+};
+
+// declare comp_ht_n_entries fixed bin;
+
+/* Duplicate name table */
+
+// declare dup_table_ptr pointer;
+// declare 1 duplicate_table aligned based (dup_table_ptr),
+struct duplicate_table {
+  // 2 mbz bit (18) unaligned, /* to tell it from a definition */
+  // 2 n_names fixed bin (18) unsigned unaligned,
+  // /* n in table */
+  uint64_t n_names : 18;
+  uint64_t mbz : 18;
+  uint64_t dummy0 : 28;
+
+  // 2 table (dup_table_n_names refer (duplicate_table.n_names)) aligned,
+  struct {
+    // 3 def_relp fixed bin (18) unsigned unaligned,
+    // 3 block_hdr_relp fixed bin (18) unsigned unaligned;
+    uint64_t block_hdr_relp : 18;
+    uint64_t def_relp : 18;
+    uint64_t dummy0 : 28;
+  } table[];
+};
+
+// declare dup_table_n_names fixed bin;
+
+/* The msf_map is found in the definition section of an */
+/* object MSF component. It is used by the linker to */
+/* determine whether a segment is a component of an object */
+/* MSF or a standard single-segment object. */
+
+// dcl msf_map_ptr ptr;
+// dcl 01 msf_map aligned based (msf_map_ptr),
+struct msf_map {
+  // 02 version char (8),
+  uint64_t version[2];
+
+  // 02 component_count fixed bin (15) unsigned,
+  uint64_t component_count : 15;
+  uint64_t dummy0 : 49;
+
+  // 02 my_component fixed bin (15) unsigned;
+  uint64_t my_component : 15;
+  uint64_t dummy1 : 49;
+};
+
+// dcl msf_map_version_1 char (8) static options (constant)
+// init ("msfmp1.0");
+
+// declare acc_string_ptr pointer;
+// declare 1 acc_string aligned based (acc_string_ptr),
+//   2 count fixed bin (9) unsigned unaligned,
+//   2 string character (max (3, acc_string_length) refer (acc_string.count)) unaligned,
+//   2 mbz bit (0) aligned; /* this causes the statement */
+//   /* unspec (acc_string) = ""b to zero out */
+//   /* the last word, if the string is not of length 0mod4 */
+
+// declare acc_string_length fixed bin (21);
+
+#endif
index c4a30d2..c10633e 100644 (file)
@@ -1,4 +1,5 @@
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -6,7 +7,7 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include "definition.h"
+#include "definition_dcls.h"
 #include "object_map.h"
 #include "rassert.h"
 
@@ -37,7 +38,7 @@ int main(int argc, char **argv) {
 
 found_path:
   ;
-  uint64_t *seg = mmap(
+  uint64_t *object_segment = mmap(
     NULL,
     01000000 * sizeof(uint64_t),
     PROT_READ,
@@ -45,7 +46,7 @@ found_path:
     fd,
     (off_t)0
   );
-  rassert(seg != (uint64_t *)-1);
+  rassert(object_segment != (uint64_t *)-1);
 
   uint64_t bitcount;
   {
@@ -75,20 +76,31 @@ found_bitcount:
   uint32_t wordcount = (bitcount / 36) & 0777777;
 
   struct object_map *object_map = (struct object_map *)(
-    seg + ((seg[(wordcount - 1) & 0777777] >> 18) & 0777777)
+    object_segment +
+      ((object_segment[(wordcount - 1) & 0777777] >> 18) & 0777777)
   );
   rassert(object_map->decl_vers == 2);
   rassert(object_map->identifier[0] == 0157142152137); // 'obj_'
   rassert(object_map->identifier[1] == 0155141160040); // 'map '
 
-  struct definition *definition = (struct definition *)(
-    seg + object_map->definition_offset
+  struct definition_header *definition_header = (struct definition_header *)(
+    object_segment + object_map->definition_offset
   );
 
-  printf(
-    "%06o %06o\n",
-    object_map->definition_offset + definition->segname,
-    object_map->definition_offset + definition->symbol
-  );
+  struct definition *definition;
+  for (
+    uint32_t definition_relp = definition_header->def_list_relp;
+    definition_relp;
+    definition_relp = definition->forward_relp
+  ) {
+    definition = (struct definition *)(
+      (uint64_t *)definition_header + definition_relp
+    );
+    printf(
+      "%06o %06o\n",
+      object_map->definition_offset + definition->segname_relp,
+      object_map->definition_offset + definition->name_relp
+    );
+  }
   return 0;
 }
index 7abc7b6..c8df181 100644 (file)
@@ -1,67 +1,70 @@
 #ifndef _OBJECT_MAP_H
 #define _OBJECT_MAP_H
 
-// see object_map.incl.pl1
+#include <stdint.h>
 
-// declare 1 object_map aligned based,         /* Structure describing standard object map */
+// see pl1/object_map.incl.pl1
+
+// declare 1 object_map aligned based, /* Structure describing standard object map */
 struct object_map {
-  // 2 decl_vers fixed bin,            /* Version number of current structure format */
-  uint64_t decl_vers;
+  // 2 decl_vers fixed bin, /* Version number of current structure format */
+  int64_t decl_vers : 18;
+  uint64_t dummy0 : 46;
 
-  // 2 identifier char (8) aligned,    /* Must be the constant "obj_map" */
+  // 2 identifier char (8) aligned, /* Must be the constant "obj_map" */
   uint64_t identifier[2];
 
-  // 2 text_offset bit (18) unaligned, /* Offset relative to base of object segment of base of text section */
-  // 2 text_length bit (18) unaligned, /* Length in words of text section */
+  // 2 text_offset bit (18) unaligned, /* Offset relative to base of object segment of base of text section */
+  // 2 text_length bit (18) unaligned, /* Length in words of text section */
   uint64_t text_length : 18;
   uint64_t text_offset : 18;
-  uint64_t dummy0 : 28;
+  uint64_t dummy1 : 28;
 
   // 2 definition_offset bit (18) unaligned, /* Offset relative to base of object seg of base of definition section */
   // 2 definition_length bit (18) unaligned, /* Length in words of definition section */
   uint64_t definition_length : 18;
   uint64_t definition_offset : 18;
-  uint64_t dummy1 : 28;
+  uint64_t dummy2 : 28;
 
-  // 2 linkage_offset bit (18) unaligned,      /* Offset relative to base of object seg of base of linkage section */
-  // 2 linkage_length bit (18) unaligned,      /* Length in words of linkage section */
+  // 2 linkage_offset bit (18) unaligned, /* Offset relative to base of object seg of base of linkage section */
+  // 2 linkage_length bit (18) unaligned, /* Length in words of linkage section */
   uint64_t linkage_length : 18;
   uint64_t linkage_offset : 18;
-  uint64_t dummy2 : 28;
+  uint64_t dummy3 : 28;
 
-  // 2 static_offset bit (18) unaligned,   /* Offset relative to base of obj seg of static section */
-  // 2 static_length bit (18) unaligned,   /* Length in words of static section */
+  // 2 static_offset bit (18) unaligned, /* Offset relative to base of obj seg of static section */
+  // 2 static_length bit (18) unaligned, /* Length in words of static section */
   uint64_t static_length : 18;
   uint64_t static_offset : 18;
-  uint64_t dummy3 : 28;
+  uint64_t dummy4 : 28;
 
-  // 2 symbol_offset bit (18) unaligned,       /* Offset relative to base of object seg of base of symbol section */
-  // 2 symbol_length bit (18) unaligned,       /* Length in words of symbol section */
+  // 2 symbol_offset bit (18) unaligned, /* Offset relative to base of object seg of base of symbol section */
+  // 2 symbol_length bit (18) unaligned, /* Length in words of symbol section */
   uint64_t symbol_length : 18;
   uint64_t symbol_offset : 18;
-  uint64_t dummy4 : 28;
+  uint64_t dummy5 : 28;
 
   // 2 break_map_offset bit (18) unaligned, /* Offset relative to base of object seg of base of break map */
   // 2 break_map_length bit (18) unaligned, /* Length in words of break map */
   uint64_t break_map_length : 18;
   uint64_t break_map_offset : 18;
-  uint64_t dummy5 : 28;
+  uint64_t dummy6 : 28;
 
// 2 entry_bound bit (18) unaligned,  /* Offset in text of last gate entry */
 // 2 entry_bound bit (18) unaligned, /* Offset in text of last gate entry */
   // 2 text_link_offset bit (18) unaligned, /* Offset of first text-embedded link */
   uint64_t text_link_offset : 18;
   uint64_t entry_bound : 18;
-  uint64_t dummy6 : 28;
+  uint64_t dummy7 : 28;
 
-  // 2 format aligned,                 /* Word containing bit flags about object type */
-  //   3 bound bit (1) unaligned,      /* On if segment is bound */
-  //   3 relocatable bit (1) unaligned,        /* On if segment has relocation info in its first symbol block */
-  //   3 procedure bit (1) unaligned,  /* On if segment is an executable object program */
-  //   3 standard bit (1) unaligned,   /* On if segment is in standard format (more than just standard map) */
+  // 2 format aligned, /* Word containing bit flags about object type */
+  //   3 bound bit (1) unaligned, /* On if segment is bound */
+  //   3 relocatable bit (1) unaligned, /* On if segment has relocation info in its first symbol block */
+  //   3 procedure bit (1) unaligned, /* On if segment is an executable object program */
+  //   3 standard bit (1) unaligned, /* On if segment is in standard format (more than just standard map) */
   //   3 separate_static bit(1) unaligned, /* On if static is a separate section from linkage */
-  //   3 links_in_text bit (1) unaligned,      /* On if there are text-embedded links */
+  //   3 links_in_text bit (1) unaligned, /* On if there are text-embedded links */
   //   3 perprocess_static bit (1) unaligned, /* On if static is not to be per run unit */
-  //   3 unused bit (29) unaligned;        /* Reserved */
+  //   3 unused bit (29) unaligned; /* Reserved */
   uint64_t format_unused : 29;
   uint64_t format_perprocess_static : 1;
   uint64_t format_links_in_text : 1;
@@ -70,7 +73,11 @@ struct object_map {
   uint64_t format_procedure : 1;
   uint64_t format_relocatable : 1;
   uint64_t format_bound : 1;
-  uint64_t dummy7 : 28;
+  uint64_t dummy8 : 28;
 };
 
+// declare map_ptr bit(18) aligned based; /* Last word of the segment. It points to the base of the object map. */
+
+// declare object_map_version_2 fixed bin static init(2);
+
 #endif
diff --git a/pl1/definition.incl.pl1 b/pl1/definition.incl.pl1
deleted file mode 100644 (file)
index 15f066a..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* BEGIN INCLUDE FILE definition.incl.pl1 */
-
-
-
-/****^  HISTORY COMMENTS:
-  1) change(86-05-02,Elhard), approve(86-05-02,MCR7391),
-     audit(86-07-18,DGHowe), install(86-11-20,MR12.0-1222):
-     Modified to add indirect bit to definition flags.
-                                                   END HISTORY COMMENTS */
-
-
-dcl    1 definition    aligned based,
-       2 forward               unal bit(18),   /* offset of next def */
-       2 backward      unal bit(18),   /* offset of previous def */
-       2 value         unal bit(18),
-       2 flags         unal,
-         3 new         bit(1),
-         3 ignore      bit(1),
-         3 entry               bit(1),
-         3 retain      bit(1),
-         3 argcount    bit(1),
-         3 descriptors bit(1),
-         3 indirect    bit(1),
-         3 unused      bit(8),
-       2 class         unal bit(3),
-       2 symbol                unal bit(18),   /* offset of ACC for symbol */
-       2 segname               unal bit(18);   /* offset of segname def */
-
-/* END INCLUDE FILE definition.incl.pl1 */