When compiling with -fpic, in contrast to -fPIC, use only the immediate field to index into the GOT. This saves space if the GOT is known to be small. The linker will warn if the GOT is too large for this method.
Details
Diff Detail
Event Timeline
It doesn't look like we can parse the textual asm produced by this. E.g.:
test.s:
ld [%i0+x], %i0 .common x,4,4
Then running llvm-mc -filetype=obj -position-independent -triple sparc -o test.o test.s hits an assert in SparcMCCodeEmitter::getMachineOpValue at SparcMCCodeEmitter.cpp:152, because it got parsed as a <MCOperand Expr:(x)>, not as a SparcMCExpr with the VK_SPARC_GOT13 kind, as it should.
Same failure, actually, without the -position-independent, too, actually, should've parsed as VK_SPARC_13. But at least we don't ever actually generate that on output.
lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp | ||
---|---|---|
61 | Strange that this doesn't print %got13. But, checking with gcc and gnu as, they don't support it. So, great, more magic just like %got22, %got10, %pc22, and %pc10. |
I ran into this problem before and tried to fix it. I will combine that patch with this and add the GOT13 part to the assembler.
Added support to the assembler so that it can properly parse the output generated by -fpic.
Strange that this doesn't print %got13. But, checking with gcc and gnu as, they don't support it. So, great, more magic just like %got22, %got10, %pc22, and %pc10.