From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 24823 invoked from network); 27 Nov 2021 18:02:23 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 27 Nov 2021 18:02:23 -0000 Received: from mail-lf1-f54.google.com ([209.85.167.54]) by 4ess; Sat Nov 27 12:30:00 -0500 2021 Received: by mail-lf1-f54.google.com with SMTP id bu18so32582752lfb.0 for <9front@9front.org>; Sat, 27 Nov 2021 09:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:content-transfer-encoding; bh=FyzEzJWO6krHpy+ZB/shuN6aHhBwK25yD9OCJl/SorI=; b=NCOhOW3E6r2r/FJHHw9yqBzxMD73pXCRFcZ4yBs3UayyqVRNqxYqaBj5N8qnAkPlbA Wxg8hmRlvPvFILoIZMKXsd0h4n+ZmY1TeOEUSkAVeFvRgfzOs56AzZZ8Op0GMA2UPugm dG8bEYVEeGNrEoLqrndh0CAdOD4i5Z2VX3Sk4gwluCdiGOwv981Xp59mRSjlPsrXOwtt 6Nq4A8JQ62v6zaYJoROXvshdsOTkzEWBlmiJVt3yQOlHJ6Hao55OwmoPUGmChS+tRpF8 imB4GCqkgvfHbYHZEEuI+u2zsAYuQtQUxBuF0MmNwW0LKovCAhxqphtuPzfgGkbohLw/ IazA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:content-transfer-encoding; bh=FyzEzJWO6krHpy+ZB/shuN6aHhBwK25yD9OCJl/SorI=; b=1ZrE9E07L4ulbJtt43D3xV1JZHRCHEKlXfRWUZ/0ojZhograEEgrvkw1wLr47Ns+G9 Uv7RtKKtKw9HCK98C9zDOws52OLMFvht0X56KLnHKwpnA17+NX7YIuF4vJhIRNafXMde N6FU1bYyHJ2API27FNb76T5GP6Swbi7naj274W1CQrNlQh6dlsYPW0kRGcQDTE2Sg2nY iLbpyOgqgoM5qMoYu/6R+F+RLVsbfoIVQZgAwDtIIONOTQeP9noCne4r6SqsEeqtApC6 jDrDRsoR3k6bU0yvUPkoMZnd3fFBdsChq0fFU5QVNpcVzVOkux+PZBBMSCT3gFih3zgn VHaA== X-Gm-Message-State: AOAM531OOozJifREpWlAAAL4tXNLcgOUElKD371HRUQsrmS7U4yL3jKP Xqq54BCAHIb3ey8w/nLMepHLyfGFfjw= X-Google-Smtp-Source: ABdhPJwa9fdVn83Dap8RYXECNycKUsHfJb2Zpm80MTSd+siu9WqODCGGUcgRwiy6fkIFyoAvCXrvhA== X-Received: by 2002:adf:cc8d:: with SMTP id p13mr21442614wrj.274.1638027540141; Sat, 27 Nov 2021 07:39:00 -0800 (PST) Return-Path: Received: from beryllium.local (dialin-80-228-141-217.ewe-ip-backbone.de. [80.228.141.217]) by smtp.gmail.com with ESMTPSA id m36sm10895359wms.25.2021.11.27.07.38.59 for <9front@9front.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 07:38:59 -0800 (PST) Received: from localhost (beryllium.local [local]) by beryllium.local (OpenSMTPD) with ESMTPA id 870471d7 for <9front@9front.org>; Sat, 27 Nov 2021 16:38:56 +0100 (CET) Date: Sat, 27 Nov 2021 15:38:55 +0000 From: Humm To: 9front@9front.org Message-ID: Mail-Followup-To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: object-oriented basic cloud strategy self-signing generator Subject: [9front] [PATCH] a.out(6): document dynamically loadable modules Reply-To: 9front@9front.org Precedence: bulk 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 .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 , 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.