The C code below extern __attribute__((pure)) int pf (int *); extern int bar;
int foo (void) { return pf (&bar);} is wrongly compiled with -fPIC on sh64-elf. The output doesn't any references to the symbol bar: .section .text..SHmedia32,"ax" .align 2 .global _foo .type _foo, @function _foo: addi.l r15, -24, r15 st.l r15, 12, r18 st.l r15, 8, r14 st.l r15, 4, r12 movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12 shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12 .LPCS0: ptrel/u r12, tr0 gettr tr0, r12 add.l r15, r63, r14 ld.l r2, 0, r2 movi ((([EMAIL PROTECTED]) >> 16) & 65535), r1 shori (([EMAIL PROTECTED]) & 65535), r1 ldx.l r1, r12, r1 ptabs r1, tr0 blink tr0, r18 add.l r14, r63, r15 ld.l r15, 4, r12 ld.l r15, 8, r14 ld.l r15, 12, r18 addi.l r15, 24, r15 ptabs r18, tr0 blink tr0, r63 .size _foo, .-_foo I confirmed that 3.4/4.0 behaves same and 3.3.6 compiler produces the sane code. So this is a regression from 3.3 to 3.4/4.0/4.1. -- Summary: Wrong code generation for the argument of the pure function in PIC Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kkojima at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: sh64-unknown-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20331