Commit graph

7357 commits

Author SHA1 Message Date
George Koehler a41b6f0458 Allow more PowerPC instructions in relocations.
I need this for relocations in lis/lfd pairs.  I add lfd along with
addi, lfs, lha, stfs, stfd to the list.
2017-01-23 16:19:38 -05:00
George Koehler a585ddf578 Fix parameters of signal handlers for linuxppc.
Linux passes the arguments in registers, but our compiler expects
arguments on the stack.  Signal handlers got garbage instead of the
signal number.  Some handlers, like the one in lang/m2/libm2/sigtrp.c,
need the correct signal number.

I write a "bridge" in PowerPC assembly that moves the arguments to the
stack.  I put the bridge in sigaction(), so I provide a signal() that
calls sigaction().  I remove the *.c glob or wildcard from build.lua,
so linuxppc only compiles its own signal.c, not the other signal.c for
linux386 and linux68k.

My bridge uses sigprocmask(), so I also add sigprocmask().  Because
linux386 and linux68k use globs, they also get sigprocmask().  I sync
the header files so all three Linux platforms declare execve(),
sigprocmask(), and unlink(), but not remove(), because we have
remove() in <stdio.h>.

I am using sigaction.s to test some features that we recently added to
our PowerPC assembler.  These are the "hi16[...]" and "lo16[...]"
syntax, and also the extended names like "beq", "cmpwi", "li", "subi".
2017-01-22 00:52:32 -05:00
George Koehler 5aa2ac2246 Teach the assembler about PowerPC extended mnemonics.
Also make a few changes to basic mnemonics.  Fix typo in name of the
basic "creqv".  Add the basic "addc" and relatives, because it would
be odd to have the extended "subc" without "addc".  Fix the basic
"rldicl", "rldicr", "rldic", "rldimi" to correctly encode the 6-bit MB
field.  Fix "slw" and relatives to correctly swap their RA and RS
operands.

Add many, but not all, of the extended mnemonics from IBM's Power ISA
Version 2.06 Book I Appendix E.  (I used 2.06, published 2009, just
because I already had the PDF of it.)  This commit includes mnemonics
for branching, subtraction, traps, bit rotation, and a few others,
like "mflr" and "nop".  The assembler now understands branches like
`beq cr7, label` and bit shifts like `slwi r7, r7, 2`.  These encode
the same machine instructions as the basic "bc" and "rlwinm".

Some operands to basic names become optional.  The assembler no longer
requires the level in "sc" or the branch hint in "bcctr" and "bclr";
they default to zero.  Some extended names take an optional branch
hint or condition register.

Some extended names are still missing.  I don't provide names with
static branch prediction, like "beq+" or "bge-", because the assembler
parses '+' and '-' as operators, not as part of an instruction name.
I also don't provide some names that 2.06 has for moving to or from
the condition register or some special purpose registers, names like
"mtcr" or "mfuamr".

This commit also deletes some unused tokens and one unused yacc rule.
2017-01-21 23:49:29 -05:00
David Given b30eeb4169 Merge pull request #46 from kernigh/kernigh-pr-man
Tune the installed manual pages.
2017-01-20 00:06:09 +01:00
George Koehler f91bc2804d Tune the installed manual pages.
This commit slightly improves the formatting of the manuals.  My
OpenBSD machine uses mandoc(1) to format manuals.  I check the manuals
with `mandoc -T lint` and fix most of the warnings.  I also make
other changes where mandoc didn't warn me.

roff(7) says, "Each sentence should terminate at the end of an input
line," but we often forgot this rule.  I insert some newlines after
sentences that had ended mid-line.

roff(7) also says that blank lines "are only permitted within literal
contexts."  I delete blank lines.  This removes some extra blank lines
from mandoc's output.  If I do want a blank line in the output, I call
".sp 1" to make it in man(7).  If I want a blank line in the source,
but not the output, I put a plain dot "." so roff ignores it.

Hyphens used for command-line options, like \-a, should be escaped by
a backslash.  I insert a few missing backslashes.

mandoc warns if the date in .TH doesn't look like a date.  Our manuals
had a missing date or the RCS keyword "$Revision$".  Git doesn't
expand RCS keywords.  I put in today's date, 2017-01-18.

Some manuals used tab characters in filled mode.  That doesn't work.
I use .nf to turn off filled mode, or I use .IP in man(7) to make the
indentation without a tab character.

ack(1) defined a macro .SB but never used it, so I delete the
definition.  I also remove a call to the missing macro .RF.

mandoc warns about empty paragraphs.  I deleted them.  mandoc also
warned about these macro pairs in anm(1):

    .SM
    .B text

The .SM did nothing because the .B text is on a different line.  I
changed each pair to .SB for small bold text.

I make a few other small changes.
2017-01-18 23:02:30 -05:00
David Given d7df126730 Merge pull request #44 from kernigh/kernigh-pr-as
mach/proto/as: allow more tokens
2017-01-18 23:33:40 +01:00
David Given 1a5c595a12 Merge pull request #45 from davidgiven/dtrg-fixups
Add hi16[], ha16[], lo16[] support to the PowerPC assembler
2017-01-18 20:18:04 +01:00
David Given 9cc264cfee Add a man page for the PowerPC assembler (not used anywhere yet). 2017-01-18 20:10:16 +01:00
David Given d5a83fd73e Clean up the led includes. 2017-01-18 19:55:56 +01:00
George Koehler f705339f86 Allow more tokens in the assembler.
I need this so I can add more %token lines to mach/powerpc/as/mach2.c

The assembler's tempfile encoded each token in a byte.  This only
worked with tokens 0 to 127 and 256 and 383.  If a token 384 or higher
existed, the assembler stopped working.  I need tokens 384 and higher.

I change the token encoding to a 2-byte little-endian integer.  I also
change a byte in the string encoding.
2017-01-17 22:41:11 -05:00
David Given 01a61e0708 Apply kernigh@'s fix to broken symbol tables in aelflod (via mailing list patch):
---snip---
The ELF spec at http://www.sco.com/developers/gabi/ says, "In each
symbol table, all symbols with STB_LOCAL binding precede the weak and
global symbols," and that sh_info is the index of the first non-local
symbol.

I was mixing local and global symbols and setting sh_info to zero. I
also forgot to set the type of the .shstrtab section.
---snip---
2017-01-18 00:06:14 +01:00
David Given 232545606d Merge from default. 2017-01-18 00:02:32 +01:00
George Koehler ba2a03705e Use prototypes in mach/proto/as/comm5.c
Order the function prototypes in comm1.h to match the order of the
function definitions in *.c files.
2017-01-17 16:41:29 -05:00
David Given 81c677d218 Add a bunch more set operations to the PowerPC backends, and the Pascal test
for the same.
2017-01-17 22:31:38 +01:00
George Koehler 916d270534 Delay inclusion of <stdint.h> when compiling comm2.y
See issue #1 (https://github.com/davidgiven/ack/issues/1).  The file
mach/proto/as/comm2.y goes through cpp twice.  The _include macro,
defined in comm2.y and used in comm0.h, delays the inclusion of system
header files.  The inclusion of <stdint.h> wasn't delayed.  This
caused multiple inclusions of <sys/_types.h> in FreeBSD and
<machine/_types.h> in OpenBSD.

Use _include to delay <stdint.h>.  Also use _include for "arch.h" and
"out.h", because h/out.h includes <stdint.h> and h/arch.h might
include it in the future.

Sort the system includes in comm0.h by moving them up to be with
<stdint.h>.  Must include <stdint.h> before "mach0.c", because
mach/powerpc/as/mach0.c needs it.  Must include "mach0.c" before
checking ASLD.
2017-01-16 22:39:44 -05:00
George Koehler e97116c037 Remove some obsolete code that causes a gcc warning.
In my OpenBSD/amd64 system, the code becomes

    if (0)
        outname.on_valu &= ~(((0xFFFFFFFF)<<32)<<32);

The 0xFFFFFFFF is a 32-bit int, so the left shift by 32 is out of
range and causes the gcc warning.

The intent might be to clear any sign-extended bits, if the assignment
outname.on_valu = valu did sign extension.  Old C had no unsigned
long, so .on_valu would have been long.  The code is obsolete because
h/out.h now declares .on_valu as uint32_t.
2017-01-16 18:09:55 -05:00
David Given c471f617b7 Ensure that memory is zero-initialised. 2017-01-16 22:45:03 +01:00
David Given 2cdcc16bc2 Fix a buffer overrun that was manifesting on OpenBSD; also fix a bounds check and some uninitialised variable problems. 2017-01-16 22:44:37 +01:00
David Given fa5675d439 Run through clang-format. 2017-01-16 21:16:33 +01:00
David Given 09c79b7dba Fix cosmetic warning when compiling B. 2017-01-15 23:00:17 +01:00
David Given c4ad07fdfc Merge pull request #40 from davidgiven/dtrg-pas
Make Pascal sets work on PowerPC (both ncg and mcg); make Pascal know about 8-bit bytes.
2017-01-15 22:56:06 +01:00
David Given b32be06881 Allow the full 8-bit byte range when reading program source. 2017-01-15 22:41:11 +01:00
David Given 5fd1634830 Rename the test to something more sensible. 2017-01-15 22:33:41 +01:00
David Given 5ff983ad9b Increase the number of items in a char set from 128 to 256, to cover all
possible bytes (7-bit bytes are so 70s).
2017-01-15 22:30:25 +01:00
David Given e7e29d34ff Add a test (currently failing) to check that Pascal char sets can store all 256
possible values. Add the PowerPC ncg and mcg backend support to let the test
actually run, including modifying a bunch of PowrePC libem functions so that
they can be called from both ncg and mcg.
2017-01-15 22:28:14 +01:00
David Given 1ea46f6afe Actually tell the user which tests failed. 2017-01-15 22:26:09 +01:00
David Given b63a4513d5 Add missing header. 2017-01-15 12:04:47 +01:00
David Given 9a346c382d Turns out Apple's hi16/ha16 exactly match my ha16/has16, so renamed
accordingly. (Memo to self: read the docs *before* doing the work.)
2017-01-15 11:59:33 +01:00
David Given f80acfe9f5 Signed vs unsigned lower halves of powerpc fixups are now handled by having two
assembler directives, ha16() and has16(), for the upper half; has16() applies
the sign adjustment. .powerpcfixup is now gone, as we generate the relocation
in ha*() instead. Add special logic to the linker for undoing and redoing the
sign adjustment when reading/writing fixups. Tests still pass.
2017-01-15 11:51:37 +01:00
David Given 14aab21204 Revert change; addis/ori requires different handling to addis/lwz due to ori's
payload being unsigned while lwz's payload is signed.
2017-01-15 10:31:20 +01:00
David Given 3c0bc205fc Update the hi/lo syntax to be a bit more standard. 2017-01-15 10:21:02 +01:00
David Given 8edbff9795 Add assembler support for fixing up arbitrary oris/addi pairs of instructions;
this should allow oris/lwz constant value loads, which will save an opcode.
2017-01-15 00:15:01 +01:00
David Given fd83b09c58 Fix typo. 2017-01-08 18:53:59 +01:00
David Given 612e14b4b4 Improve confusing error message when calling function procedures from a
top-level statement.

Fixes: #30
2017-01-08 11:25:57 +01:00
David Given ee5ef73dfb Run through clang-format. 2017-01-08 11:23:56 +01:00
David Given 62022c6f6b Don't print source file names during compilation (gcc stopped doing it years
ago).
2017-01-08 00:16:35 +01:00
David Given 4b7fc5e233 Run through clang-format. 2017-01-08 00:15:23 +01:00
David Given 11ea3a2fe1 Don't sort inludes any more (breaks too many ACK files). 2017-01-08 00:15:10 +01:00
David Given 51862cff82 Merge pull request #32 from dram/add-execve
Add execve() system call for Linux
2017-01-07 23:23:00 +01:00
David Given 893471a42e No longer truncate module names at 10 characters when constructing paths;
rename some library modules to their full names.
2017-01-07 23:00:52 +01:00
David Given d50a6f99de Run through clang-format. 2017-01-07 22:56:00 +01:00
David Given cca6171e55 Properly install man pages. 2017-01-07 22:38:30 +01:00
David Given 9945b019d2 Add a B man page. 2017-01-07 22:35:02 +01:00
David Given a7fa54e4e0 Update the README. 2017-01-07 20:11:01 +01:00
David Given 837b9622fb Make sure that constant folding doesn't render our tests trivial. 2017-01-07 19:53:57 +01:00
David Given abbead482a Sections are now aligned (required by the EM spec). 2017-01-07 18:47:46 +01:00
David Given efab08178b Fix a bunch of issues with pushing and popping mismatched sizes, which the B
compiler does a lot; dup 8 for pairs of words is now optimised.
2017-01-07 18:47:00 +01:00
David Given 5a38ce2a69 Pre-and-post-modification operators now work substantially better (i.e.,
working).
2017-01-07 18:46:03 +01:00
David Given 39215c131e Moved the inc/dec operator tests into their own source file; more exhaustive
testing.
2017-01-07 18:38:43 +01:00
David Given 6b4f8d72b8 ine and ste are now declared to modify memory (preventing cached values being
propagated across the modification).
2017-01-07 13:25:09 +01:00