[cc65] Problems with ORG directive and linker

From: Sidney Cadot <sidney1jigsaw.nl>
Date: 2011-03-30 14:28:11
Hi guys,

I have a very silly linker problem. I am assembling a (slightly
modified version) of very old code with ca65. The code has a lot of
".org" directives. What I am trying to do is generate a 64K memory map
of the software after compilation, but I can't get the linker to do
what I want.

Allow me to give a simple example demonstrating the problem I have.
Suppose I have the file "foobar.s" that looks like this:

$ cat foobar.s
; ========== start of foobar.s

        .org $e000

foo:    jmp bar

bar:    rts

; ========== end of foobar.s

Assembling works fine:


$ ca65 -l foobar.s
$ cat foobar.lst
ca65 V2.13.2 - (C) Copyright 1998-2005 Ullrich von Bassewitz
Main file   : foobar.s
Current file: foobar.s

000000r 1               ; ========== start of foobar.s
000000r 1
000000r 1                       .org $e000
00E000  1
00E000  1  4C 03 E0     foo:    jmp bar
00E003  1
00E003  1  60           bar:    rts
00E004  1
00E004  1               ; ========== end of foobar.s
00E004  1


On to linking. Suppose I have this very simple linker configuration:

$ cat simple.cfg
########## start of simple.cfg

memory {
    EntireMemorySpace : start = $0000, size =$10000, fill = yes;
}

segments {
    CODE : load = EntireMemorySpace;
}

########## end of simple.cfg

However, when I use it for linking the previously generated "foobar.o"
to "a.out", the code ends up at the start of the "a.out" file rather
than at offset 0xE000:

$ ld65 -C simple.cfg foobar.o
$ od -Ax4 -tx1 -w1 a.out
000000 4c
000001 03
000002 e0
000003 60
000004 00
*
010000



So, I am probably doing something stupid here. Who can help out?

Best regards, Sidney
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Mar 30 14:28:25 2011

This archive was generated by hypermail 2.1.8 : 2011-03-30 14:28:29 CEST