9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] a.out(6): document dynamically loadable modules
@ 2021-11-27 15:38 Humm
  2021-12-04 23:25 ` Humm
  2023-03-02  4:31 ` ori
  0 siblings, 2 replies; 12+ messages in thread
From: Humm @ 2021-11-27 15:38 UTC (permalink / raw)
  To: 9front


The loaders can generate export tables in executables and build
dynamically loadable modules and there is a library to load those
floating around.  This documents the format of dynamically loadable
modules.
---
I’m sure I’m bad at wording.

---
diff e2a8d3493ab0fdc345b6513a53f30f2b4f36ed97 43b5a35ac0af25c778899143766e1003fb821830
--- a/sys/man/6/a.out	Mon Nov 22 00:42:13 2021
+++ b/sys/man/6/a.out	Sat Nov 27 16:07:35 2021
@@ -4,10 +4,10 @@
 .SH SYNOPSIS
 .B #include <a.out.h>
 .SH DESCRIPTION
-An executable Plan 9 binary file has up to six sections:
-a header, the program text, the data,
-a symbol table, a PC/SP offset table (MC68020 only),
-and finally a PC/line number table.
+An executable Plan 9 binary file has up to seven sections: a header,
+the program text, the data, a symbol table, a PC/SP offset table
+(MC68020 only), a PC/line number table, and finally relocation data
+(dlm only).
 The header, given by a structure in
 .BR <a.out.h> ,
 contains 4-byte integers in big-endian order:
@@ -26,6 +26,7 @@
 } Exec;
 
 #define HDR_MAGIC	0x00008000	/* header expansion */
+#define DYN_MAGIC	0x80000000	/* dynamically loadable module */
 
 #define	_MAGIC(f, b)	((f)|((((4*(b))+0)*(b))+7))
 #define	A_MAGIC	_MAGIC(0, 8)		/* 68020 */
@@ -259,6 +260,48 @@
 first previous
 .B z
 symbol in the symbol table.
+.PP
+In dynamically loadable modules, relocation data follows directly
+after the PC/line number table.
+It starts with the 4-byte big-endian size of the following data, which
+consists of an import table and a relocation table.
+The import table starts with the 4-byte big-endian number of imported
+symbols, followed by a list of entries, laid out as:
+.IP
+.EX
+u32int sig;	/* big-endian */
+char   name[\f2n\fP];	/* NUL-terminated */	
+.EE
+.PP
+.I Sig
+is the type signature value generated by the C compiler's
+.B signof
+operator applied to the type.
+.I Name
+is the linkage name of the function or data.
+.PP
+The relocation table starts with the 4-byte big-endian number of
+fixups, followed by a list of those, each laid out as:
+.IP
+.EX
+uchar m;
+uchar ra[\f2c\fP];
+.EE
+.PP
+The four low bits of
+.I m
+are an architecture-dependent relocation mode.
+.I C
+is 2 raised to the power of the two high bits of
+.IR m ,
+which can be 0, 1, or 2.
+.I Ra
+is a big-endian increment of the working address in the module.
+Each iteration in the process of relocation, the working address is
+incremented by the current
+.IR ra .
+Then, the value in the module at the working address is modified as
+specified by the relocation mode.
 .SH "SEE ALSO"
 .IR db (1), 
 .IR acid (1), 
@@ -273,3 +316,5 @@
 .B -a
 flags on the compilers will produce symbols for
 .IR acid (1).
+.PP
+Dynamically loadable modules exist, and aren't even used anywhere.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-03-02  4:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-27 15:38 [9front] [PATCH] a.out(6): document dynamically loadable modules Humm
2021-12-04 23:25 ` Humm
2021-12-04 23:35   ` Sigrid Solveig Haflínudóttir
2021-12-04 23:49     ` Eli Cohen
2021-12-04 23:49       ` Eli Cohen
2021-12-04 23:52         ` Eli Cohen
2021-12-05  0:01           ` Kurt H Maier
2021-12-05  1:01           ` Humm
2021-12-05  0:48     ` Humm
2021-12-05 21:08       ` Steve Simon
2021-12-06  0:47         ` Humm
2023-03-02  4:31 ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).