8.4.2 Element pointer (ep)

The element pointer is a pointer that is provided to realize faster access (loading and storing) by allocating data (variables) that are globally declared within an application to RAM area in RH850 device.

Data (variables) that is globally declared and allocated to internal RAM area is referenced with ep-relative.

(1)

Setting the element pointer (ep)

Set the value of the element pointer symbol (ep symbol) as the address set in the global pointer (ep).

-

The ep symbol is handled as the constant symbol name "__ep_data".

-

Declare the ep symbol as a reference symbol (.extern) in the startup routine.

-

rlink creates an externally defined symbol (.public) and determines the address of the ep symbol.

-

The operations for defining and referencing the ep symbol are as follows.

(a)

If there is only an ".extern" declaration of the ep symbol

rlink creates the definition information and sets the address automatically.

(b)

If the ep symbol is defined

The defined address is used.

(c)

If there is no ep symbol (it is not used)

The following error message is output for code that makes references relative to the ep.

Undefined external symbol "EP-symbol (__ep_data)" referenced in "FILE"

(2)

Rules for determining the ep symbol value

The value of the ep symbol is determined from sections with relocation attributes of tdata, tdata4/5/7/8, tbss4/5/7/8, edata, ebss, edata23 and ebss23, in the following order of precedence.

Figure 8.2

Rules for Determining the Element Pointer Value

 

Below is an example of how the value of the ep symbol is determined.

(a)

If there are sections with relocation attributes of tdata, tdata4/5/7/8, and tbss4/5/7/8

The ep symbol is set to the start address of the first section in this order: tdata -> tdata4, or tbss4 -> ... -> tdata8, or tbss8.

(b)

If there is a section with a relocation attribute of edata or ebss

Sets the halfway point between the start address of the edata or ebss section with the smallest address, and the end address of the edata or ebss section with the greatest address (multiple of 2; if the midway point is an odd number, takes the first multiple of two) as the address value of the ep symbol.

<1>

If an edata and ebss section are located in this order, from smallest to highest address

<2>

If an ebss and edata section are located in this order, from smallest to highest address

<3>

If edata and ebss sections are placed in this order, from lowest to highest address, and there is a non-eligible section in between the edata and ebss sections

(c)

If there is a section with a relocation attribute of edata23 or ebss23

Sets the halfway point between the start address of the edata23 or ebss23 section with the smallest address, and the end address of the edata23 or ebss23 section with the greatest address (multiple of 2; if the midway point is an odd number, takes the first multiple of two) as the address value of the ep symbol.

<1>

If an edata23 and ebss23 section are located in this order, from smallest to highest address

<2>

If an ebss23 and edata23 section are located in this order, from smallest to highest address

<3>

If edata23 and ebss23 sections are placed in this order, from lowest to highest address, and there is a non-eligible section in between the edata23 and ebss23 sections

(d)

If there are no sections with tdata, tdata4/5/7/8, tbss4/5/7/8, edata, ebss, edata23, or ebss23 relocation attributes

If there are no data, tdata4/5/7/8, tbss4/5/7/8, edata, ebss, edata23, or ebss23 sections, then the address value of the ep symbol is set to zero (0).