Re: [cc65] Accessing linker symbols from C?

From: thefox xofeht <>
Date: 2011-11-17 20:18:56
On Thu, Nov 17, 2011 at 9:01 PM, Joseph Rose <> wrote:
> How do I, from C code, access symbols from the linker?  Let's say I create a
> buffer in memory as a segment and want to fill it with a document.  The
> problem is that when I try to read the starting address of a defined memory
> segment (i.e. __BSS_LOAD__), I get a zero value.  I need the starting
> address and size of the segment.  BTW, I know to remove the initial '_' and
> have been defining the label as extern in a header.

I don't know if there's a better way to do this (probably not), but
from C's point of view everything is an address. If you do something
like "extern int foo;" and then try accessing "foo", it will read an
int from the address marked by the symbol "_foo". So to get what you
should do something like this:

extern void _BSS_LOAD__;
int bss_load = ( int )&_BSS_LOAD__;

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Nov 17 20:19:07 2011

This archive was generated by hypermail 2.1.8 : 2011-11-17 20:19:10 CET