[Bug c++/92572] Vague linkage does not work reliably when a matching segment is in a dynamically linked libarary on Linux
wkaras at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Mon Feb 10 23:35:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92572
--- Comment #4 from Walt Karas <wkaras at yahoo dot com> ---
(conanrunenv) [root@d761696b8abf VagueDynLink]# cc -O2 -Wall -Wextra -pedantic
-std=c++17 -fno-strict-aliasing -fwrapv -S main.cc
(conanrunenv) [root@d761696b8abf VagueDynLink]# cat main.s
.file "main.cc"
.text
.section
.text._ZNSt11char_traitsIcE6lengthEPKc,"axG",@progbits,_ZNSt11char_traitsIcE6lengthEPKc,comdat
.p2align 4,,15
.weak _ZNSt11char_traitsIcE6lengthEPKc
.type _ZNSt11char_traitsIcE6lengthEPKc, @function
_ZNSt11char_traitsIcE6lengthEPKc:
.LFB419:
.cfi_startproc
jmp strlen
.cfi_endproc
.LFE419:
.size _ZNSt11char_traitsIcE6lengthEPKc,
.-_ZNSt11char_traitsIcE6lengthEPKc
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "./lib.a"
.LC1:
.string "dlopen() failed: "
.LC2:
.string "lib"
.LC3:
.string "lib() not found\n"
.LC4:
.string "dlsym() fail: "
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB1854:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movl $2, %esi
movl $.LC0, %edi
pushq %rbx
.cfi_def_cfa_offset 24
.cfi_offset 3, -24
subq $24, %rsp
.cfi_def_cfa_offset 48
call dlopen
testq %rax, %rax
je .L9
movl $.LC2, %esi
movq %rax, %rdi
movq %rax, %rbx
call dlsym
testq %rax, %rax
je .L5
call *%rax
leaq 15(%rsp), %rbp
.L6:
movl _ZZ3foovE12static_local(%rip), %eax
movl $_ZSt4cout, %edi
leal 1(%rax), %esi
movl %esi, _ZZ3foovE12static_local(%rip)
call _ZNSolsEi
movq %rbp, %rsi
movl $1, %edx
movb $10, 15(%rsp)
movq %rax, %rdi
call
_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
movq %rbx, %rdi
call dlclose
addq $24, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
xorl %eax, %eax
popq %rbx
.cfi_def_cfa_offset 16
popq %rbp
.cfi_def_cfa_offset 8
ret
.L5:
.cfi_restore_state
call dlerror
movq %rax, %rbp
testq %rax, %rax
je .L10
movl $.LC4, %edi
call _ZNSt11char_traitsIcE6lengthEPKc
movl $.LC4, %esi
movl $_ZSt4cout, %edi
movq %rax, %rdx
call
_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
movq %rbp, %rsi
movl $_ZSt4cout, %edi
leaq 15(%rsp), %rbp
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
movl $1, %edx
movq %rbp, %rsi
movb $10, 15(%rsp)
movq %rax, %rdi
call
_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
jmp .L6
.L10:
movl $.LC3, %esi
movl $_ZSt4cout, %edi
leaq 15(%rsp), %rbp
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
jmp .L6
.L9:
movl $.LC1, %edi
call _ZNSt11char_traitsIcE6lengthEPKc
movl $.LC1, %esi
movl $_ZSt4cout, %edi
movq %rax, %rdx
call
_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
call dlerror
movl $_ZSt4cout, %edi
movq %rax, %rsi
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
movl $1, %edx
leaq 15(%rsp), %rsi
movb $10, 15(%rsp)
movq %rax, %rdi
call
_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
movl $1, %edi
call exit
.cfi_endproc
.LFE1854:
.size main, .-main
.p2align 4,,15
.type _GLOBAL__sub_I_main, @function
_GLOBAL__sub_I_main:
.LFB2309:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $_ZStL8__ioinit, %edi
call _ZNSt8ios_base4InitC1Ev
movl $__dso_handle, %edx
movl $_ZStL8__ioinit, %esi
movl $_ZNSt8ios_base4InitD1Ev, %edi
addq $8, %rsp
.cfi_def_cfa_offset 8
jmp __cxa_atexit
.cfi_endproc
.LFE2309:
.size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main
.section .init_array,"aw"
.align 8
.quad _GLOBAL__sub_I_main
.weak _ZZ3foovE12static_local
.section
.bss._ZZ3foovE12static_local,"awG",@nobits,_ZZ3foovE12static_local,comdat
.align 4
.type _ZZ3foovE12static_local, @gnu_unique_object
.size _ZZ3foovE12static_local, 4
_ZZ3foovE12static_local:
.zero 4
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.hidden __dso_handle
.ident "GCC: (GNU) 8.3.1 20190311 (Red Hat 8.3.1-3)"
.section .note.GNU-stack,"",@progbits
More information about the Gcc-bugs
mailing list