Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/outfmt.src
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,21 @@ directive as \c{elf} does: see \k{elfglob} for documentation of
this.


\H{aout2fmt} \i\c{aout2}: \i{OS/2}
\I{a.out, OS/2 version}\c{a.out} Object Files

The \c{aout2} output format is the same as \c{aout}. In addition,

\c{aout2} provides \c{EXPORT} to export DLL symbols like \c{obj}. See \k{export}.
However, \c{aout2} supports \e{external} name and \e{ordinal} only.

For example:

\c export myfunc
\c export myfunc TheRealMoreFormalLookingFunctionName
\c export myfunc myfunc 1234 ; export by ordinal


\H{as86fmt} \c{as86}: \i{Minix}/Linux\I{linux, as86} \i\c{as86} Object Files

The Minix/Linux 16-bit assembler \c{as86} has its own non-standard
Expand Down
111 changes: 107 additions & 4 deletions output/outaout.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "outform.h"
#include "outlib.h"

#if defined OF_AOUT || defined OF_AOUTB
#if defined OF_AOUT || defined OF_AOUTB || defined OF_AOUT2

#define RELTYPE_ABSOLUTE 0x00
#define RELTYPE_RELATIVE 0x01
Expand Down Expand Up @@ -64,6 +64,7 @@ struct Symbol {
* More flags used in Symbol.type.
*/
#define SYM_GLOBAL 1 /* it's a global symbol */
#define SYM_EXPORT 0x6C /* it's an exported symbol on OS/2 */
#define SYM_DATA 0x100 /* used for shared libs */
#define SYM_FUNCTION 0x200 /* used for shared libs */
#define SYM_WITH_SIZE 0x4000 /* not output; internal only */
Expand Down Expand Up @@ -283,7 +284,10 @@ static void aout_deflabel(char *name, int32_t segment, int64_t offset,
sym = saa_wstruct(syms);

sym->strpos = pos;
sym->type = is_global ? SYM_GLOBAL : 0;
if (is_global == 4)
sym->type = SYM_EXPORT;
else
sym->type = is_global ? SYM_GLOBAL : 0;
sym->segment = segment;
if (segment == NO_SEG)
sym->type |= SECT_ABS;
Expand All @@ -310,7 +314,7 @@ static void aout_deflabel(char *name, int32_t segment, int64_t offset,
sbss.asym = sym;
} else
sym->type = SYM_GLOBAL;
if (is_global == 2)
if (is_global == 2 || is_global == 4)
sym->value = offset;
else
sym->value = (sym->type == SYM_GLOBAL ? 0 : offset);
Expand Down Expand Up @@ -838,9 +842,80 @@ static void aout_sect_write(struct Section *sect,
sect->len += len;
}

#ifdef OF_AOUT2

static enum directive_result
aout2_directive(enum directive directive, char *value)
{
switch (directive) {
case D_EXPORT:
/* Is pass_first() really correct? */
if (value && pass_first()) {
char *q, *extname, *intname, *v;
unsigned int ordinal = 0;
bool err;
/* .stabs "<exportname>,<ordinal>=<asmname>,<code|data>", 0x6C,0,0,-42 */
char export[255 + 1 + 5 + 1 + 255 + 1 + 4 + 1];

intname = q = value;
while (*q && !nasm_isspace(*q))
q++;
if (nasm_isspace(*q)) {
*q++ = '\0';
while (*q && nasm_isspace(*q))
q++;
}

extname = q;
while (*q && !nasm_isspace(*q))
q++;
if (nasm_isspace(*q)) {
*q++ = '\0';
while (*q && nasm_isspace(*q))
q++;
}

if (!*intname) {
nasm_nonfatal("`export' directive requires export name");
return DIRR_ERROR;
}
if (!*extname)
extname = intname;
while (*q) {
v = q;
while (*q && !nasm_isspace(*q))
q++;
if (nasm_isspace(*q)) {
*q++ = '\0';
while (*q && nasm_isspace(*q))
q++;
}
err = false;
ordinal = readnum(v, &err);
if (err) {
nasm_nonfatal("invalid ordinal `%s'", v);
return DIRR_ERROR;
}
}
/* assume function */
snprintf(export, sizeof(export), "%s,%d=%s,%s",
extname, ordinal, intname, "code");
aout_deflabel(export, stext.index, -42, 4, NULL);
}
return DIRR_OK;

default:
return DIRR_UNKNOWN;
}
}

#endif

#if defined(OF_AOUT) || defined(OF_AOUTB)
extern macros_t aout_stdmac[];
#endif

#endif /* OF_AOUT || OF_AOUTB */
#endif /* OF_AOUT || OF_AOUTB || OF_AOUT2 */

#ifdef OF_AOUT

Expand Down Expand Up @@ -893,3 +968,31 @@ const struct ofmt of_aoutb = {
};

#endif

#ifdef OF_AOUT2

extern macros_t aout2_stdmac[];

const struct ofmt of_aout2 = {
"OS/2 a.out",
"aout2",
".o",
0,
32,
null_debug_arr,
&null_debug_form,
aout2_stdmac,
aout_init,
null_reset,
aout_out,
aout_deflabel,
aout_section_names,
NULL,
null_sectalign,
null_segbase,
aout2_directive,
aout_cleanup,
NULL /* pragma list */
};

#endif
8 changes: 8 additions & 0 deletions output/outaout.mac
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ OUT: aout aoutb
%define __?SECT?__ [section .text]
%macro __?NASM_CDecl?__ 1
%endmacro

OUT: aout2
%define __?SECT?__ [section .text]
%macro __?NASM_CDecl?__ 1
%endmacro
%imacro export 1+.nolist
[export %1]
%endmacro
17 changes: 15 additions & 2 deletions output/outform.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* OF_name -- ensure that output format 'name' is included
* OF_NO_name -- remove output format 'name'
* OF_DOS -- ensure that 'obj', 'obj2', 'bin', 'win32' & 'win64' are included.
* OF_UNIX -- ensure that 'aout', 'aoutb', 'coff', 'elf32' & 'elf64' are in.
* OF_UNIX -- ensure that 'aout', 'aoutb', 'aout2', 'coff', 'elf32' & 'elf64' are in.
* OF_OTHERS -- ensure that 'bin', 'as86', 'rdf' 'macho32' & 'macho64' are in.
* OF_ALL -- ensure that all formats are included.
* note that this doesn't include 'dbg', which is
Expand Down Expand Up @@ -56,7 +56,7 @@

/* ====configurable info begins here==== */
/* formats configurable:
* bin,obj,obj2,elf32,elf64,aout,aoutb,coff,win32,as86,rdf2,macho32,macho64 */
* bin,obj,obj2,elf32,elf64,aout,aoutb,aout2coff,win32,as86,rdf2,macho32,macho64 */

/* process options... */

Expand Down Expand Up @@ -94,6 +94,9 @@
#ifndef OF_AOUTB
#define OF_AOUTB
#endif
#ifndef OF_AOUT2
#define OF_AOUT2
#endif
#ifndef OF_WIN32
#define OF_WIN32
#endif
Expand Down Expand Up @@ -146,6 +149,9 @@
#ifndef OF_AOUTB
#define OF_AOUTB
#endif
#ifndef OF_AOUT2
#define OF_AOUT2
#endif
#ifndef OF_COFF
#define OF_COFF
#endif
Expand Down Expand Up @@ -203,6 +209,9 @@
#ifdef OF_NO_AOUTB
#undef OF_AOUTB
#endif
#ifdef OF_NO_AOUT2
#undef OF_AOUT2
#endif
#ifdef OF_NO_COFF
#undef OF_COFF
#endif
Expand Down Expand Up @@ -237,6 +246,7 @@ extern const struct ofmt of_ith;
extern const struct ofmt of_srec;
extern const struct ofmt of_aout;
extern const struct ofmt of_aoutb;
extern const struct ofmt of_aout2;
extern const struct ofmt of_coff;
extern const struct ofmt of_elf32;
extern const struct ofmt of_elfx32;
Expand Down Expand Up @@ -270,6 +280,9 @@ static const struct ofmt * const drivers[] = {
#ifdef OF_AOUTB
&of_aoutb,
#endif
#ifdef OF_AOUT2
&of_aout2,
#endif
#ifdef OF_COFF
&of_coff,
#endif
Expand Down