From: Humm <hummsmith42@gmail.com>
To: 9front@9front.org
Subject: [9front] [PATCH] a.out(6): document dynamically loadable modules
Date: Sat, 27 Nov 2021 15:38:55 +0000 [thread overview]
Message-ID: <YaJRD6FgwU8Bn8j/@beryllium.local> (raw)
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.
next reply other threads:[~2021-11-27 18:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-27 15:38 Humm [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YaJRD6FgwU8Bn8j/@beryllium.local \
--to=hummsmith42@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).