This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/51880] New: protected visibility does not link


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51880

             Bug #: 51880
           Summary: protected visibility does not link
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org
            Target: x86_64-*-*


__attribute__((visibility("protected")))
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
foo:
.LFB0:
        .cfi_startproc
        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
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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]