Skip to content

Commit

Permalink
usr.bin/as: Recognize MIPS ".module" directive.
Browse files Browse the repository at this point in the history
The .module directive, added to binutils gas in 2014, allows
command line options to be set in the assembler source code.

Recognize and parse, but ignore, the ".module" directive.

This allows MIPS assembler generated by newer versions of gcc
to be recognized, and not fail on the .module directive.

The format recognized is ".module name[=name]".
E.g., ".module fp=32" ".module oddspreg" ".module arch=mips32r2"

The /tools/aoututils version has also been changed, to keep in sync.
  • Loading branch information
chettrick committed Feb 24, 2024
1 parent 1746e10 commit a6de7b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tools/aoututils/as/as.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum {
LWEAK, /* .weak */
LLOCAL, /* .local */
LNAN, /* .nan */
LMODULE, /* .module */
};

/*
Expand Down Expand Up @@ -733,6 +734,7 @@ int lookacmd ()
break;
case 'm':
if (! strcmp (".mask", name)) return (LMASK);
if (! strcmp (".module", name)) return (LMODULE);
break;
case 'n':
if (! strcmp (".nan", name)) return (LNAN);
Expand Down Expand Up @@ -2349,6 +2351,20 @@ done: reorder_flush();
if (csegm != SABS)
uerror ("bad value of .size");
break;
case LMODULE:
/* .module name[=name] */
clex = getlex (&cval);
if (clex != LNAME)
uerror ("bad parameter of .module");
clex = getlex (&cval);
if (clex != '=') {
ungetlex (clex, cval);
break;
}
clex = getlex (&cval);
if (clex != LNAME)
uerror ("bad parameter of .module");
break;
default:
uerror ("bad syntax");
}
Expand Down
16 changes: 16 additions & 0 deletions usr.bin/as/as.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum {
LWEAK, /* .weak */
LLOCAL, /* .local */
LNAN, /* .nan */
LMODULE, /* .module */
};

/*
Expand Down Expand Up @@ -733,6 +734,7 @@ int lookacmd ()
break;
case 'm':
if (! strcmp (".mask", name)) return (LMASK);
if (! strcmp (".module", name)) return (LMODULE);
break;
case 'n':
if (! strcmp (".nan", name)) return (LNAN);
Expand Down Expand Up @@ -2349,6 +2351,20 @@ done: reorder_flush();
if (csegm != SABS)
uerror ("bad value of .size");
break;
case LMODULE:
/* .module name[=name] */
clex = getlex (&cval);
if (clex != LNAME)
uerror ("bad parameter of .module");
clex = getlex (&cval);
if (clex != '=') {
ungetlex (clex, cval);
break;
}
clex = getlex (&cval);
if (clex != LNAME)
uerror ("bad parameter of .module");
break;
default:
uerror ("bad syntax");
}
Expand Down

0 comments on commit a6de7b1

Please sign in to comment.