This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question on LD Linker providing low 2 bytes of address as a constant


I am using GCC and LD to build for a ColdFire processer.  My application
is a port of existing C and assembly code for an Intel processor.  So, I
will start off by saying I am probably trying to do things that are not
typical or in the norm.  And often I want to do things to minimize the
overal project risk.

In this case, there are things I am specifically storing in low memory
(address can fit in 2 bytes).  These things are stored places and used
all as 2 byte addresses.  They are then cast to real pointers when they
need to be dereferenced.

My problem is this.  I have some constant tables (stored in flash) that
need to contain the 2 byte address of another table.  If I end up
needing to change these to 4 bytes being stored in the table, this has a
large impact on my project.  So, before going to that, I want to make
sure I have explored every option possible to get the linker to store
the low 2 bytes of an address in my constant table.  My constant table
is a table of structures that contains among other things a 2 byte
address of another table (which is stored in low memory).  I will refer
to this item in the structure as HdlrTbl and the table that contains the
2 byte pointer as StructTbl just for ease of discussion.  So, StructTbl
is an array of structures containing HdlrTbl.  HdlrTbl is defined as 2

If I put the address of the table I wanted stored in HdlrTbl in my
pre-initializer, the compiler reports "error: initializer element is not
constant".  If I change HdlrTbl from 2 bytes to 4 bytes and leave the
pre-initilizer the way it was, it compiles fine.  So it looks like I
need a way to tell the compiler and linker that I only want the lowest 2
bytes of the address (which is identical to the address since the 2 high
bytes are 0).

Any help you could give me would be greatly appreciated.

Doreen Miller
Tyco Fire & Security - SimplexGrinnell
50 Technology Dr.
Westminster, MA 01441
978 731-8541

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]