[Bug target/19520] protected function pointer doesn't work right

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 18 09:35:00 GMT 2012


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

--- Comment #25 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-18 09:21:14 UTC ---
LD bug: http://sourceware.org/bugzilla/show_bug.cgi?id=13600

The GCC side is a QOI thing and maybe a conformance thing.  ICC generates
for

__attribute__((visibility("protected")))
void * foo (void) { return (void *)foo; }

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

thus does not resolve the function address to the local symbol, which GCC
does and which confuses LD (thus the linker bug):

        .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

I think ICC this way avoids the function pointer comparison issues with
symbols with protected visibility (can someone double-check?  HJs testcase
doesn't compile for me).



More information about the Gcc-bugs mailing list