Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Original a.out specification query

23 views
Skip to first unread message

Robert Pengelly

unread,
Feb 7, 2024, 9:31:52 AMFeb 7
to
I've been doing a little research into a.out and found two references that I'm confused about.

Looking at https://gunkies.org/wiki/UNIX_a.out_file it has:

Offset Contents
0 A magic number (below)
2 Program text size
4 Initialized data size
6 Uninitialized (BSS) data size
010 Symbol table size
012 Entry location
014 Unused
016 Flag indicating relocation information has been suppressed

and looking at https://www.bell-labs.com/usr/dmr/www/man51.pdf it has:

The header always contains 6 words:
1 a “br .+14” instruction (205(8))
2 The size of the program text
3 The size of the symbol table
4 The size of the relocation bits area
5 The size of a data area
6 A zero word (unused at present)

What size is a word exactly? I know that a.out is from the original Unix that ran on the PDP-7/PDP-11 but I don't know what a word size was (16-bits vs 32-bits).

Scott Lurndal

unread,
Feb 7, 2024, 10:17:29 AMFeb 7
to
Robert Pengelly <roberta...@gmail.com> writes:
>I've been doing a little research into a.out and found two references that =
>I'm confused about.
>
>Looking at https://gunkies.org/wiki/UNIX_a.out_file it has:
>
>Offset Contents
>0 A magic number (below)
>2 Program text size
>4 Initialized data size
>6 Uninitialized (BSS) data size
>010 Symbol table size
>012 Entry location
>014 Unused
>016 Flag indicating relocation information has been suppressed=20
>
>and looking at https://www.bell-labs.com/usr/dmr/www/man51.pdf it has:
>
>The header always contains 6 words:
>1 a =E2=80=9Cbr .+14=E2=80=9D instruction (205(8))
>2 The size of the program text
>3 The size of the symbol table
>4 The size of the relocation bits area
>5 The size of a data area
>6 A zero word (unused at present)
>
>What size is a word exactly? I know that a.out is from the original Unix t=
>hat ran on the PDP-7/PDP-11 but I don't know what a word size was (16-bits =
>vs 32-bits).
16 bits.

Here's /usr/include/a.out.h from unix v7. Int is 16 bits.

struct exec { /* a.out header */
int a_magic; /* magic number */
unsigned a_text; /* size of text segment */
unsigned a_data; /* size of initialized data */
unsigned a_bss; /* size of unitialized data */
unsigned a_syms; /* size of symbol table */
unsigned a_entry; /* entry point */
unsigned a_unused; /* not used */
unsigned a_flag; /* relocation info stripped */
};

#define A_MAGIC1 0407 /* normal */
#define A_MAGIC2 0410 /* read-only text */
#define A_MAGIC3 0411 /* separated I&D */
#define A_MAGIC4 0405 /* overlay */

struct nlist { /* symbol table entry */
char n_name[8]; /* symbol name */
int n_type; /* type flag */
unsigned n_value; /* value */
};

/* values for type flag */
#define N_UNDF 0 /* undefined */
#define N_ABS 01 /* absolute */
#define N_TEXT 02 /* text symbol */
#define N_DATA 03 /* data symbol */
#define N_BSS 04 /* bss symbol */
#define N_TYPE 037
#define N_REG 024 /* register name */
#define N_FN 037 /* file name symbol */
#define N_EXT 040 /* external bit, or'ed in */
#define FORMAT "%06o" /* to print a value */

Robert Pengelly

unread,
Feb 7, 2024, 10:27:35 AMFeb 7
to
Okay, so the origin a.out had 16-bit (2-byte) header fields making the header 16 bytes instead of 32 bytes? Where did the whole 07 01 64 00 at the start come from? Or when did the 64 00 get added? I know the 07 01 is the 0407 signature it's just the next two bytes I'm querying.
0 new messages