Bug 51880 - protected visibility does not link
Summary: protected visibility does not link
Status: RESOLVED DUPLICATE of bug 19520
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on:
Reported: 2012-01-17 12:13 UTC by Richard Biener
Modified: 2012-01-17 20:00 UTC (History)
0 users

See Also:
Target: x86_64-*-*
Known to work:
Known to fail: 3.4.0, 4.7.0
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2012-01-17 12:13:25 UTC
void * foo (void) { return (void *)foo; }

does not link:

> gcc t1.c -o libt1.so -shared -fPIC
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: t1.o: relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

which is because we assemble to:

        .globl  foo
        .protected      foo
        .type   foo, @function
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        leaq    foo(%rip), %rax

ICC otoh generates

        .protected foo
        .globl foo
..B1.1:                         # Preds ..B1.0
..___tag_value_foo.1:                                           #1.60
        movq      foo@GOTPCREL(%rip), %rax                      #1.77

and properly

     6: 00000000000005b0    16 FUNC    GLOBAL PROTECTED   11 foo

I'm using binutils 2.22 in case this is an assembler problem.
Comment 1 Richard Biener 2012-01-17 12:14:26 UTC
Assembler seems to be the same since forever.
Comment 2 Richard Biener 2012-01-17 12:15:58 UTC
GAS can assemble the ICC assembly just fine and we can then link it just fine.
Comment 3 Richard Biener 2012-01-17 12:33:07 UTC
bas/ld bug:

Comment 4 Andrew Pinski 2012-01-17 20:00:27 UTC
Dup of 19520

*** This bug has been marked as a duplicate of bug 19520 ***