Bug 65058 - AIX: missing extern decorations "[DS]" for functions and "[UA]" for variables
Summary: AIX: missing extern decorations "[DS]" for functions and "[UA]" for variables
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-13 21:36 UTC by Michael Haubenwallner
Modified: 2015-02-24 20:20 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc-ibm-aix
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Haubenwallner 2015-02-13 21:36:12 UTC
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).
Comment 1 Michael Haubenwallner 2015-02-13 21:40:53 UTC
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.
Comment 2 Michael Haubenwallner 2015-02-13 22:04:02 UTC
Proposed patch: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00885.html
Comment 3 David Edelsohn 2015-02-16 15:33:42 UTC
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
Comment 4 David Edelsohn 2015-02-16 15:42:30 UTC
Fixed.
Comment 5 David Edelsohn 2015-02-16 23:04:04 UTC
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
Comment 6 haubi 2015-02-24 20:20:25 UTC
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