This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: efficient memory access from assembly


> Hi.
> 
> I am currently porting code (both C and assembler) from the ARM toolkit to the
> GNU GCC environment. Reading through the documentstion of GCC, I can't figure
> out how to port register relative memory access instructions without duplicating
> information. So what I have is a (relocatable) area of data storage, where space
> is allocated for a number of variables.
> Having the base-address of this area in a register (say r5), I would like to be
> able to perform accesses of the kind
> 
> 	ldr	r1, [r5, #<variablename>]
> 
> so <variablename> must be the offset from the base-address. The location of the
> code accessing the variables must be completely independent from the area where
> the variables are stored at assembly-time, and the variables need to be
> accessible to code in different files. Must this be done using {absolute}
> addresses, which overlap at link-time, or does anybody have a better idea?
> 

I may have mis-understood what you are asking here, so apologies if I'm 
talking baloney.

It looks to me like you are asking if the assembler supports based data 
regions.  If so, then I think you are asking in the wrong list 
(binutils@sources.redhat.com would be a better place to ask).  I think you 
will find the answer is no, but I could be wrong.

If we really are talking about C, then GCC for the ARM does not support 
position-independent data, so about the best I can suggest is to create a 
large struct containing all the symbols that you want to access off a 
single base.  You then might be able to set up the base registers with 
gcc-isms, for example an asm statement.

Richard.


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