I try compile program with following options :powerpc-8xx-eabi-gcc -fverbose-asm -O2 -I../include -meabi -memb -msdata=eabi -Wa,-al -G10000 hello.c -o hello.o The test program is simple one (end of this mail ) The manual clearly states: -msdata=eabi On System V.4 and embedded PowerPC systems, put small initialized const global and static data in the .sdata2 section, which is pointed to by register r2. Put small initialized non-const global and static data in the .sdata section, which is pointed to by register r13. So, the all data unnder 10000 bytes hould put in small data sections and addressed with register relative instructions but this does not happen. I even checked from produced assembly listing that it uses la instruction ( addi %r,0,<immediate>) instead using addi %r,%r2,<immediate> that forms address relative to r2 ( or r13 ) Also storing the valu e i is 52 0028 90000000 stw 0,i@sda21(0) # i instead sww 0,i(2) Also, i can't pass it to linker because it gives relocation truncated to fit: R_PPC_EMB_SDA21 hellos Ithis my be my fault mut least i have not found solution anywhere how to make register relative ( position independent) data to wark. The my main goal is just compile position independent code and data for my open source Katix rtos. I ahave also tried many gcc versions starting from 2.x.x and got no-one working. Kate const char hellos[] = "hello: Hello, world!\n\r"; volatile int i; int _start() { for(;;) { i=my_strlen(hellos); i=my_strlen("hello: Hello, world!\n\r"); } } int my_strlen(char *s) { int i=0; while(*s++) i++; return i; }
*** Bug 14745 has been marked as a duplicate of this bug. ***
*** Bug 14744 has been marked as a duplicate of this bug. ***
Did you try with -fPIC or -fpic as I think PPC eabi is non-pic by default?
Subject: Re: -msdata=eabi does not produce r2/r13 relative access pinskia at gcc dot gnu dot org wrote: >------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-26 15:19 ------- >Did you try with -fPIC or -fpic as I think PPC eabi is non-pic by default? > > > Yes i did. The -fpic does not produce position independent data access, only position independent code section. All data access including acces to cons data is still position dependnet. For some reason compiler also says that -fpic and -msdata=eabi are incompatible but i don't understand why. Ty be truly position independent, allow loading to any address in non mmu processor memory, both data and program should be position independent and so data should be also register relative as descripted for -msdata=eabi. Kate
I'm not so sure this is a valid complaint. There are other thing we don't put into .sdata2, for example function addresses (see pr16343).
Reported almost 4 years ago, never confirmed. Is this still valid?
.