Compile the following file with -fvisibility=hidden int foo; void bar(void) { foo = 0; }
You will find that the assembler rejects the .s file that the compiler creates, giving the error: /var/tmp//cclfEVh7.s:16:non-relocatable subtraction expression, "_foo" minus "L00000000001$pb" /var/tmp//cclfEVh7.s:16:symbol: "_foo" can't be undefined in a subtraction expression The assembler is right to complain. The compiler generates these lines: addis r2,r31,ha16(_foo-"L00000000001$pb") la r2,lo16(_foo-"L00000000001$pb")(r2) This is incorrect. Common symbols must be treated as undefined symbols, so they must be addressed indirectly through non-lazy pointers. Without -fvisibility=hidden, the compiler gets this right. -- Summary: -fvisibility=hidden causes bad codegen for common symbols Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: austern at apple dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: powerpc-apple-darwin7.6.0 GCC host triplet: powerpc-apple-darwin7.6.0 GCC target triplet: powerpc-apple-darwin7.6.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19041