tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] add an executable format?


From: tccm
Subject: Re: [Tinycc-devel] add an executable format?
Date: Tue, 17 Jan 2023 08:23:34 +0100

On Mon, Jan 16, 2023 at 05:21:26PM +0100, tccm wrote:
> Would some developer familiar with the tinycc internals be kind to help
> with adding the needed minimal aout support, by giving directions
> for the modification or, best of all, by adding the support?
> 
> There is no need to handle aout object files, only statically linked
> executables.

Answering an off-list question:

It is known how the header fields need to be initialized on Minix-2.

The proof-of-concept code is about as follows:

struct  exec {
        unsigned short a_magic;
        unsigned char a_flags;
        unsigned char a_cpu;
        unsigned char a_hdrlen;
        unsigned char a_unused;
        unsigned short a_version;
        unsigned a_text;
        unsigned a_data;
        unsigned a_bss;
        unsigned a_entry;
        int      a_total;
        int      a_syms;
};

    aex.a_magic = 0x301;       /* OMAGIC */
    aex.a_flags = 0x10;        /* flags, A_EXEC 0x10 executable, 0x20 sep I&D */
    aex.a_cpu = 0x10;          /* cpu id, A_I80386 0x10 intel i80386 */
    aex.a_hdrlen = 32;         /* length of header, 32 */
    aex.a_unused = 0;          /* reserved for future use */
    aex.a_version = 0;         /* version stamp (not used at present) */

    aex.a_text = text.len;
    aex.a_data = data.len;
    aex.a_bss = bss.len;
    aex.a_entry = 0xb4; /* the value that works in our tinycc experiments */

    aex.a_total = 131072 + data.len + bss.len;
                  /* extra 128K is hardcoded here as an example, this
                  is the amount of memory OS will allow the process
                  to allocate; a command line argument to tinycc can
                  be helpful, but there is a tool to adjust this limit
                  afterwards */

    aex.a_syms = 0; /* size of symbol table */

OTOH the differences between various aout flavours are quite small when we
only need to create executables. If there were f.i. corresponding support
for Linux a.out, it would be a trivial matter to adjust for Minix-2.

/tccm




reply via email to

[Prev in Thread] Current Thread [Next in Thread]