Relative PIC data not addressed correctly in structs?
Hi,
I'm using the options -std=c99 -mcpu=cortex-a7 -mfpu=vfpv4 -fpic -mpic-data-
gcc version 4.9.3 20150529 (release) [ARM/embedded-
My code looks like.
typedef struct
{
const char* msg;
} str_t;
static str_t str_tab[] =
{
{"string1"},
{"string2"}
};
int main(void)
{
str_t* str = str_tab;
const char* msg = str_tab[0].msg;
return 0;
}
Linker file:
SECTIONS
{
ENTRY(__main)
.text 0x86000000:
{
RO_CODE_LMA = . ;
RO_CODE_VMA = . ;
hwc_boot.obj (.text .rodata)
RW_CODE_LMA = . ;
hwa_exc.obj (.text .rodata)
RW_
*(.text* .rodata*)
*(.glue_7t)
*(.glue_7)
RO_
}
.ARM.extab . :
{
*
}
.ARM.exidx . :
{
__exidx_start = . ;
*(.ARM.exidx* .gnu.linkonce.
__exidx_end = . ;
}
.data . :
{
RW_DATA_LMA = . ;
RW_DATA_VMA = . ;
*(.data)
RW_
}
.bss . :
{
ZI_DATA = . ;
*(.bss)
ZI_DATA_END = . ;
}
.nidata . :
{
NI_DATA = . ;
hwa_
*(.nidata)
NI_DATA_END = . ;
}
.rwtext ALIGN(256) : AT (RW_CODE_VMA)
{
RW_CODE_VMA = . ;
RW_EXC_CODE = . ;
hwa_exc.obj (.text .rodata)
}
RW_STACK_
.shared 0x8603fe00 (NOLOAD) :
{
RW_SHARED_LMA = . ;
RW_
}
RO_CODE_LEN = RO_CODE_LMA_END - RO_CODE_LMA;
RW_CODE_LEN = RW_CODE_LMA_END - RW_CODE_LMA;
RW_DATA_LEN = RW_DATA_LMA_END - RW_DATA_LMA;
NI_DATA_LEN = NI_DATA_END - NI_DATA;
ZI_DATA_LEN = ZI_DATA_END - ZI_DATA;
RW_SHARED_LEN = RW_SHARED_LMA_END - RW_SHARED_LMA;
RW_TT_LMA = . ;
RW_TT_LMA_END = . ;
RW_TT_VMA = . ;
RW_TT_LEN = 0;
}
I load my SW into the memory at an offset from the original linkage offset that is specified in my linker file. I.e. instead of 0x86000000 I force my SW to be loaded into 0x86000100. Now the line str_t* str = str_tab works perfectly fine and that variable is relative to the PC. But when I try to fetch a string in the string table the pointer to that string always points to a fixed address as if the SW was loaded in 0x86000000.
Am I expecting to much from -mpic-data-
Thanks.
/ Henrik
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Henrik for more information if necessary.