Sorry, don't bother. I have to admit that I temporarily disabled the optimizations to avoid inlining and forgot to enable them after the problem got fixed (because it manifested without optimizations as well.) You may have built another gcc for nothing.
Looking at the -O2 output (after using noinline, etc.), I can see that the executable is generated correctly, but expects dynamic relocation processing, which you don't have. In particular, there is one dynamic relocation pointing into GOT. It should be theoretically possible to generate position independent code without fixups, but I don't know how to coerce the compiler.
I will dig some more, but if noone else posts otherwise, we can assume that you are supposed to either fully process the relocations or try the GOT trick that the linux kernel decompressor uses. In both cases, I can see how this may not be what you originally aimed for with PIC.
Here is what I've got with O2:
Code:
# /usr/local/i686-elf/bin/i686-elf-objdump -R test-i686
test-i686: file format elf32-i386
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00001280 R_386_RELATIVE *ABS*
# /usr/local/i686-elf/bin/i686-elf-objdump -h test-i686
test-i686: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 000000d4 000000d4 000000d4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .hash 0000000c 000000e8 000000e8 000000e8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .dynsym 00000010 000000f4 000000f4 000000f4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynstr 00000001 00000104 00000104 00000104 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rel.dyn 00000008 00000108 00000108 00000108 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .text 0000006b 00000110 00000110 00000110 2**4
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
6 .eh_frame 00000084 0000017c 0000017c 0000017c 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
7 .dynamic 00000080 00001200 00001200 00000200 2**2
CONTENTS, ALLOC, LOAD, DATA
8 .got 00000004 00001280 00001280 00000280 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .got.plt 0000000c 00001284 00001284 00000284 2**2
CONTENTS, ALLOC, LOAD, DATA
10 .data 00000000 00001290 00001290 00000290 2**0
CONTENTS, ALLOC, LOAD, DATA
11 .bss 0000000c 00001290 00001290 00000290 2**2
ALLOC
12 .comment 00000011 00000000 00000000 00000290 2**0
CONTENTS, READONLY
P.S.: If you are wondering what the goal of PIC on Linux is, it is to allow relocation fixup entirely outside the code segment. This enables sharing the code pages between multiple processes. However, apparently creating relocation-free code is either not a priority, or is produced with another set of options that I am not aware of.