Re: [cc65] rebuilding libraries - generated program crashes

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-06-07 22:00:43


Hi!

Thanks for the detailed description. I'm sorry that I didn't note this
earlier, but the linker acts exactly as it should. Have a look at the
linker configuration for the Apple (this file is part of the source
package and comes in the doc/ directory of the apple2 binary package):

    MEMORY {
        ZP: start = $00, size = $1A, type = rw, define = yes;
        HEADER: start = $0000, size = $4, file = %O;
        RAM: start = $800, size = $8E00, file = %O;
    }
    SEGMENTS {
        EXEHDR: load = HEADER, type = ro;
        STARTUP: load = RAM, type = ro, define = yes;
        LOWCODE: load = RAM, type = ro, optional = yes;
        CODE: load = RAM, type = ro;
        RODATA: load = RAM, type = ro;
        DATA: load = RAM, type = rw;
        BSS: load = RAM, type = bss, define = yes;
        ZEROPAGE: load = ZP, type = zp;
    }

What you can see is that the AppleDOS 3.3 header which comes in the EXEHDR
segment is written into the HEADER memory area, which goes to the output
file ("%O" is the output file named on the command line).

The STARTUP segment, which contains the code from crt0.s is the first
segment that is written to the RAM memory area, which is relocated to $800
and which goes into the same file as the header.

This means that the output file contains 4 bytes of header, followed by
code that must be loaded to $800. So either the loader has to strip the
first 4 bytes and load the remainder to $800, or you have to load the
whole file to $7FC so that the STARTUP segment begins at $800.

As you can see, there is no error, anything works as it should. I'm not
sure why you insist on loading the whole file to $800. If this is based on
some information in the docs, the docs are wrong. In this case please tell
me where you found the information so I can fix it.

Older versions of cc65 produced apple2 binaries without the header. It has
been added later by request of the AppleWin author (Oliver Schmidt). His
statement was that both, AppleDOS 3.3 and ProDOS are both able to use this
header.

If you don't want the header, just modify line 3 of the linker config so
that it reads:

        HEADER: start = $0000, size = $4, file = "";

This will dump the header by assigning an empty output file. Then apply
the changed linker config by using

        ld65 -C apple2.cfg ...

instead of

        ld65 -t apple2 ...

The latter command uses the builtin version of the apple2 linker
configuration as shown above.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-06-07 22:00:54 CEST