I need to define a variable at a fixed address of 0x100000 (this is an
eeprom address, and for reliability reasons this data needs to reside
there) and I am wondering how I can do this with the lcc tools.
I've tried specifically moving this variable to its own separate file
and then modifying the linker script to place it where I want. But
trouble is the variable is actually a struct made up of structs
defined in other files, and since the header file myvar.h has
#include's to other files, those other file's variables get into
myvar.o. So instead of only myvar being defined at address 0x100000, I
get all the stuff in file1.h and file2.h as well as myvar being
defined at 0x100000 which is not what I want. I only want myvar
located at 0x100000. I want the other stuff located in the
normal .text, .data, or .bss sections.
Can I do this with a linker script? Or is there a #pragma for lcc that
will let me define my own custom sections and place this variable in
that section then use the linker script to place the section where I
want it?
Here's what I've got right now:
myvar.h
-------------
#include "file1.h" // contains other variable declarations
#include "file2.h" // contains other variable declarations
typedef struct
{
File1Type a;
File2Type b;
}MyVarType;
myvar.c
-----------
#include "myvar.h"
MyVarType myvar;
linker script
----------------
SECTIONS
{
.text LOAD_ADDR :
{
c_text_start = ABSOLUTE(.);
start.o(.text)
*( .text)
*(.rodata)
c_text_end = ABSOLUTE(.);
}
.data :
{
c_data_start = ABSOLUTE(.);
*(.data)
*(.sdata)
*(.sdata2)
c_data_end = ABSOLUTE(.);
}
.bss :
{
c_bss_start = ABSOLUTE(.);
*(EXCLUDE_FILE(myvar.o).bss)
*(.sbss)
*(COMMON)
c_bss_end = ABSOLUTE(.);
}
.eeprom 0x100000 :
{
myvar.o(.bss)
}
|
|
0
|
|
|
|
Reply
|
scubakathy84 (1)
|
6/16/2010 8:55:54 PM |
|
km <scubakathy84@gmail.com> wrote:
> I need to define a variable at a fixed address of 0x100000 (this is an
> eeprom address, and for reliability reasons this data needs to reside
> there) and I am wondering how I can do this with the lcc tools.
The traditional way is not to use a variable, but a pointer assigned
the desired address appropriately cast. If that isn't good enough,
it can usually be faked using the preprocessor, such that it looks
like a variable in most contexts.
If that isn't good enough, a better explanation might help.
-- glen
|
|
0
|
|
|
|
Reply
|
glen
|
6/16/2010 9:50:22 PM
|
|