__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.
Assembler seems to be the same since forever.
GAS can assemble the ICC assembly just fine and we can then link it just fine.
bas/ld bug: http://sourceware.org/bugzilla/show_bug.cgi?id=13600
Dup of 19520 *** This bug has been marked as a duplicate of bug 19520 ***