Commit Graph

32 Commits

Author SHA1 Message Date
Stephen Heumann 740f75cff5 Add script to set filetypes. 2023-08-06 17:49:51 -05:00
Stephen Heumann ac725a6207 Bump version number to 2.1.0 final. 2023-06-29 19:53:22 -05:00
Stephen Heumann 850952d612 Treat ORG records as giving a signed offset from the current location.
This is the way they are defined in the GS/OS Reference, as well as the way they seem to be used by all assemblers and all other linkers that I could check (ORCA/M, MPW AsmIIGS, Apple LinkIIGS, old ORCA/APW LINKED, 8-bit ORCA linker).

Previously, this linker treated ORG records as giving an absolute address to ORG to (but with a bug in the address computation). The OMF spec in appendix B of the ORCA/M manual defines them this way, but this is inconsistent with the spec in the GS/OS Reference and with the way ORG records are generated by ORCA/M itself (for an ORG *+expression directive). Therefore, I think this is just an error and the specification in the GS/OS Reference should be regarded as correct.

We still do not support going backward (using a negative ORG operand). Trying to do so will just give an error.
2022-09-26 21:32:28 -05:00
Stephen Heumann 9f232e883a Avoid spurious errors when evaluating EQU/GEQU expressions.
Shifting is now prohibited only for relocatable expressions. It is fine if a shift operator is used with constant operands, simply producing another constant.

Also, spurious errors about using multiple load segments in an expression are no longer reported just because of the load segment "containing" the EQU/GEQU record. Since it does not actually translate to anything in the load file, that segment does not matter.
2022-09-25 21:49:01 -05:00
Stephen Heumann da13b94a43 Properly evaluate non-constant expressions in EQU/GEQU records.
Previously, the values of such expressions were essentially ignored, resulting in incorrect output.

This affected code like the following example:

test1   start
        lda     >p

D1      data
p       gequ    val

val     data
        dc      i'123'

Note that the EQU/GEQU expression is evaluated within the context of the location that references it, not the location where it is defined. This affects the value of the location counter, as well as the symbol search behavior. The references for the OMF format do not clearly define which way this should be done, but the current behavior can cause problems with certain object files produced by ORCA/M.
2022-09-25 21:42:20 -05:00
Stephen Heumann 0b275e5b22 Set position-independent flag only if it is set in all object segments.
Previously, the position-independent attribute bit would be set in a load segment if it was set on the first constituent object segment. Now it is only set in the load segment if it is set in all the constituent object segments. This is consistent with the ORCA linker's general approach of conservatively combining the flags from the object segments.
2022-08-30 19:46:22 -05:00
Stephen Heumann 085c7c46ca Add support for auto-segmentation.
This is a new feature where the linker will automatically divide the code into load segments, creating as many segments as necessary to fit it. This relieves the programmer from the need to manually figure out how a large program can be divided into segments.

Auto-segmentation is triggered by the use of the special load segment name AUTOSEG~~~. Using this approach (rather than a flag in the OMF header) allows auto-segmentation to be used with all existing languages that provide a mechanism for specifying load segment names.
2022-08-30 19:32:09 -05:00
Stephen Heumann 3bb2802f2f Update modification date in comment. 2021-08-30 21:39:03 -05:00
Stephen Heumann 390fd96ede Do not report an error when the segment length equals the bank size.
This is legal per the OMF definition in the GS/OS Reference (and it is accepted by the loader), so it should not be treated as an error.
2021-08-26 22:21:44 -05:00
Stephen Heumann ea3550bfcc Update release notes. 2021-03-03 23:35:07 -06:00
Stephen Heumann ef5360eddd Fix the make script to use actual names of macro files. 2021-03-03 23:27:28 -06:00
Stephen Heumann 47460f34bb Fix check for valid alignment values.
Previously, the high 16 bits were being ignored. Therefore, the valid alignment value $10000 was rejected, but values that were not a power of 2 may have been accepted. The new code properly enforces that the alignment is a power of 2, and is <= $10000.
2021-03-03 23:26:08 -06:00
Stephen Heumann 8aa3c4e8c7 Give error about excessive alignment at the right time.
The error "Alignment factor must not exceed segment align factor" is now given when an ALIGN record with greater alignment than its segment is encountered. (This is the error that was given erroneously in other circumstances before the last commit.)
2021-03-03 22:53:57 -06:00
Stephen Heumann aa9a585d19 Do not give spurious errors about segment alignment.
This would happen if a later object segment had a more restrictive alignment than previous object segments that contribute to the same load segment, as in the following example:

s1      start
        jsl s2

        align   256
s2      start

These alignment requirements can be satisfied by just giving the load segment the most restrictive alignment of any object segment (since all alignments are powers of 2) and inserting space as necessary to align the code from each object segment.
2021-03-03 18:41:45 -06:00
Stephen Heumann d62fdba4bb Update linker release notes. 2021-02-25 22:31:29 -06:00
Stephen Heumann 2275b137d8 Update linker version number to 2.0.6. 2021-02-25 22:29:56 -06:00
Stephen Heumann 76ba56a36b Allow 2-byte RELEXPR records to be used for branches of + or - 64KB.
Previously, the linker gave an error if the relative displacement was more than + or - 32 KB. But 2-byte RELEXPR records are typically used for the operand of the BRL instruction, and since its address calculation wraps around within the program bank, it can effectively address + or - 64KB (i.e. any location within the program bank). Similar reasoning applies to PER, the other instruction using long relative addressing.

This would give an error in code like the following:

bigbrl  start
        brl     later
        ds      33000  ; realistic examples would have actual code here
later   rtl

(This currently also gives an assembler error due to similar logic in ORCA/M, but the output file can be linked anyway.)

This issue can affect very large functions compiled with ORCA/C or ORCA/Pascal, which may sometimes have branches that go more than 32 KB forward or back.
2021-02-19 18:18:47 -06:00
Stephen Heumann 42734c7433 Update linker release notes. 2018-09-15 16:40:45 -05:00
Stephen Heumann 1a643585e8 Update linker version number to 2.0.5. 2018-09-15 16:40:23 -05:00
Stephen Heumann 170fa09ecc Search for object files under both lower- and upper-case extensions.
This enables the linker to work correctly with object files with either extension case (or a mix), so it can work with objects from any of the ORCA languages even on a case-sensitive filesystem.

If two object files differ only in the case of their extension, the one with the lower-case extension will be used, and the one with the upper-case extension will be ignored.
2018-09-15 16:20:18 -05:00
Stephen Heumann 433b4652d7 Accept DVR, LDF, and FST as valid KeepType values.
Note that ORCA/Shell listings use DRV for type $BB, but the File Type Notes specify DVR.
2018-09-13 18:14:09 -05:00
MikeW50 2cdbebe6e6
Merge pull request #4 from ksherlock/ci-update
use lowercase extensions (.root, .a, etc)
2018-03-25 15:35:09 -06:00
MikeW50 9bca07851b
Merge pull request #2 from ksherlock/gg_support
add makefile and file for use with Golden Gate.
2018-03-25 15:34:20 -06:00
Kelvin Sherlock a8528f35b7 use lowercase extensions (.root, .a, etc) for better compatibility with case-sensitive file systems
(ORCA/C and ORCA/Pascal use lowercase extensions for object files. ORCA/M uses uppercase extensions for object files)
2018-01-02 21:35:34 -05:00
Kelvin Sherlock 1ec542fde5 fix typos. 2017-10-23 09:32:39 -04:00
Stephen Heumann 346516654c Update linker release notes. 2017-10-21 22:29:39 -05:00
Stephen Heumann 3099720543 Update linker version number to 2.0.4. 2017-10-21 22:29:26 -05:00
Stephen Heumann 7328e38c27 Fix bug in handling of pathname buffers at the very beginning of a bank. 2017-10-08 20:47:06 -05:00
Stephen Heumann 877e84cdb3 Fix bugs in handling of symbol table entries at the very beginning of a bank.
These bugs could manifest themselves as (at least) bogus "Addressing error" or "expression too complex" messages.
2017-10-08 20:46:55 -05:00
Kelvin Sherlock ce65f20394 add makefile and ninja file for use with Golden Gate. 2017-10-02 16:01:45 -04:00
Kelvin Sherlock c21ae46a4d convert CR files to LF for better git compatibility. 2017-10-02 09:35:05 -04:00
mikew50 748ae356d7 The ORCA Linker 2.0.3 from the Opus ][ CD 2017-10-01 21:26:59 -06:00