With gcc-4.2, references to external functions and variables were decorated with "[DS]" and "[RW]", respectively. With gcc-4.8, these decorations are missing, even though ASM_OUTPUT_EXTERNAL (xcoff.h) pretends to add them. $ cat > extref.c <<EOF extern int externvar; extern void externfunc(void); int *localvar = &externvar; void (*localfunc)(void) = externfunc; EOF $ gcc-4.2.4 -S extref.c -o - | grep extern .long externvar[RW] .long externfunc[DS] $ gcc-4.8.4 -S extref.c -o - | grep extern .long externvar .long externfunc The latter may lead to the linker error ld: 0711-317 ERROR: Undefined symbol: .externfunc in the corner case when: *) externfunc is imported via an Import File *) externfunc() is used as direct function call *) externfunc is used to initialize a function pointer *) there is some larger number of symbols to import, so no small testcase. My particular problem is with openssh linking against the Import File libcrypto.so(shr.imp).
Probably this happens since gcc-4.3 due to this commit: https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/varasm.c?r1=119764&r2=119763&pathrev=119764 Problem is that assemble_external() does not call ASM_OUTPUT_EXTERNAL any more to add the decorations, before the symbol is written via ASM_OUTPUT_SYMBOL_REF.
Proposed patch: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00885.html
Author: dje Date: Mon Feb 16 15:33:09 2015 New Revision: 220737 URL: https://gcc.gnu.org/viewcvs?rev=220737&root=gcc&view=rev Log: 2015-02-16 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> David Edelsohn <dje.gcc@gmail.com> PR target/65058 * config/rs6000/rs6000.c (rs6000_output_symbol_ref): Append storage mapping class to external variable or function reference. * config/rs6000/xcoff.h (ASM_OUTPUT_EXTERNAL): Do not append storage mapping class. 2015-02-16 David Eelsohn <dje.gcc@gmail.com> PR target/53348 * config/rs6000/rs6000.c (rs6000_declare_alias): Only use ASM_WEAKEN_DECL if defined. Modified: trunk/gcc/ChangeLog trunk/gcc/config/rs6000/rs6000.c trunk/gcc/config/rs6000/xcoff.h
Fixed.
Author: dje Date: Mon Feb 16 23:03:33 2015 New Revision: 220744 URL: https://gcc.gnu.org/viewcvs?rev=220744&root=gcc&view=rev Log: PR target/65058 * gcc.target/powerpc/pr65058.c: New test. Added: trunk/gcc/testsuite/gcc.target/powerpc/pr65058.c Modified: trunk/gcc/testsuite/ChangeLog
Author: haubi Date: Tue Feb 24 20:19:54 2015 New Revision: 220947 URL: https://gcc.gnu.org/viewcvs?rev=220947&root=gcc&view=rev Log: PR target/65058: Drop unused variable. PR target/65058 * config/rs6000/xcoff.h (ASM_OUTPUT_EXTERNAL): Drop unused variable. Modified: trunk/gcc/ChangeLog trunk/gcc/config/rs6000/xcoff.h