Re: [cc65] Linker - Read-only warning

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-08-30 13:26:10


On Fri, Aug 29, 2003 at 08:27:08AM -0400, Keates, Mark wrote:
> A new question arises, if I wrote:
>
> 	.segment "DATA1"
> MyData:
> 	.rodata
> MyReadOnly:
>
> Are the labels associated with the segment?
> i.e. if RODATA and DATA1 have the same base then
> would checks on STA MyData and STA MyReadOnly
> be resolvable by the proposed check?

There are several relocatable items, some generated by the assembler, others
by the linker:

    a "section" is the part of a "segment" that comes from one object file.

    a "segment" is the collection of all "sections" depending on the decision
    of the linker which object files get linked to an executable.

    a "memory area" collects several "segments" and places them at a specific
    address.

In relocatable mode (that is, without a preceeding .ORG), labels in the
assembler are actually expressions that contain a reference to a section. The
linker can resolve these expressions, because, once all necessary object files
have been determined, each section has a fixed offset into a segment. And the
segment has a fixed offset into a memory area.

In answer to your question: Yes. The labels MyData and MyReadOnly will be
generated as expressions containing a reference to the "DATA1" and "RODATA"
sections respectively, so the linker knows to which segment you're storing,
even if the actual addresses are the same.

There's one problem however, which does also pop up in other places and is
related to the flexibility of the tools: An expression can contain more than
one section reference. For example:

        special = (MyData - MyReadOnly) & $FFC0
        ...
        sta     special

In this case, the expression for the symbol "special" contains two segment
references: One to "DATA1" (coming from the MyData symbol), and one to
"RODATA" (coming from the MyReadOnly symbol). Features like the one above are
also the reason why it is not possible for the linker to convert all input to
o65 format: The o65 format (while it is quite complex for a machine like the
6502) cannot contain expressions with more than one segment reference, or with
anything else than addition or substraction of constants. There are no such
limits for the assembler/linker: Anything you're able to calculate in the
assembler may be passed to the linker; the complete expression is stored in
the object file regardless of its complexity.

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-08-30 13:27:08 CEST