https://sourceware.org/bugzilla/show_bug.cgi?id=33260

--- Comment #1 from Thiago Macieira <thiago at kde dot org> ---
gold appears to Do The Right Thing™ for the relocations, but fails at
propagating the ELF property for -mno-direct-extern-access:

$ cc -fuse-ld=gold -fPIC -DUSE_PROTECTED -O2 -fvisibility=hidden
-mno-direct-extern-access -shared -o a.so a.c b.c
/usr/bin/ld.gold: warning: /tmp/ccGnijBz.o: unknown program property type
-1342144512 in .note.gnu.property section

Relocation for my_func disappears from the relocation table:
$ objdump -R a.so                      
DYNAMIC RELOCATION RECORDS
OFFSET           TYPE              VALUE
0000000000001db8 R_X86_64_RELATIVE  *ABS*+0x00000000000006c0
0000000000001dc0 R_X86_64_RELATIVE  *ABS*+0x0000000000000700
0000000000002010 R_X86_64_RELATIVE  *ABS*+0x0000000000002010
0000000000002020 R_X86_64_RELATIVE  *ABS*+0x0000000000000710
0000000000001fe0 R_X86_64_GLOB_DAT  __cxa_finalize@GLIBC_2.2.5
0000000000001fd8 R_X86_64_GLOB_DAT  _ITM_registerTMCloneTable
0000000000001fd0 R_X86_64_GLOB_DAT  _ITM_deregisterTMCloneTable
0000000000001fc8 R_X86_64_GLOB_DAT  __gmon_start__
0000000000002028 R_X86_64_64       my_func_overridable@@Base
0000000000002000 R_X86_64_JUMP_SLOT  __cxa_finalize@GLIBC_2.2.5
0000000000002008 R_X86_64_JUMP_SLOT  my_func_overridable@@Base

Function call is still direct, PC-relative:
$ objdump -d a.so | sed -n '/<f>/,/^$/p'
0000000000000730 <f>:
 730:   48 83 ec 08             sub    $0x8,%rsp
 734:   e8 d7 ff ff ff          call   710 <my_func>
 739:   48 8d 05 e0 18 00 00    lea    0x18e0(%rip),%rax        # 2020 <vtable>
 740:   48 83 c4 08             add    $0x8,%rsp
 744:   c3                      ret

Do note how it also adds a jump slot for the overridable function, which is
probably another bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to