Re: [cc65] Accessing linker symbols from C?

From: Joseph Rose <rose.joseph121yahoo.com>
Date: 2011-11-17 20:34:40
Thank you for your speedy response.  :)  I just need to figure out how to use the address as an integer....



________________________________
From: thefox xofeht <thefox@aspekt.fi>
To: cc65@musoftware.de
Sent: Thursday, November 17, 2011 2:18 PM
Subject: Re: [cc65] Accessing linker symbols from C?

On Thu, Nov 17, 2011 at 9:01 PM, Joseph Rose <rose.joseph12@yahoo.com> 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__;

-thefox
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Nov 17 20:34:51 2011

This archive was generated by hypermail 2.1.8 : 2011-11-17 20:34:54 CET