Date: Mon, 09 Nov 2020 20:40:52 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 250992] Binaries produced by clang -pg on x86-64 always crash in ld-elf.so.1 Message-ID: <bug-250992-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D250992 Bug ID: 250992 Summary: Binaries produced by clang -pg on x86-64 always crash in ld-elf.so.1 Product: Base System Version: 12.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: oleg.derevenetz@gmail.com Consider the following program (test.c): $ cat test.c #include <stdio.h> int main() { printf("OK\n"); } When built using the following command: $ clang -pg test.c the following binary is produced: $ file a.out a.out: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 12.2, FreeBSD-style, = with debug_info, not stripped (note the "interpreter /libexec/ld-elf.so.1" part). Once launched, it crashes inside ld-elf.so.1 with SIGSEGV: $ lldb a.out (lldb) target create "a.out" Current executable set to '/usr/home/oleg/tmp/pg/a.out' (x86_64). (lldb) run Process 872 launching Process 872 launched: '/usr/home/oleg/tmp/pg/a.out' (x86_64) Process 872 stopped * thread #1, name =3D 'a.out', stop reason =3D signal SIGSEGV: invalid addr= ess (fault address: 0x0) frame #0: 0x00000008002a3ab0 -> 0x8002a3ab0: movq (%r15), %rdx 0x8002a3ab3: cmpq $0x6fffffef, %rdx ; imm =3D 0x6FFFFFEF 0x8002a3aba: jg 0x8002a3b10 0x8002a3abc: cmpq $0x21, %rdx (lldb) disassemble -> 0x8002a3ab0: movq (%r15), %rdx 0x8002a3ab3: cmpq $0x6fffffef, %rdx ; imm =3D 0x6FFFFFEF 0x8002a3aba: jg 0x8002a3b10 0x8002a3abc: cmpq $0x21, %rdx 0x8002a3ac0: ja 0x8002a3ba6 0x8002a3ac6: movslq (%r12,%rdx,4), %rax 0x8002a3aca: addq %r12, %rax 0x8002a3acd: jmpq *%rax (lldb) Disassembled code above is apparently from ld-elf.so.1/_rtld_is_dlopened. However, if the following command is used for the build: $ clang -pg -static test.c the following binary is produced: $ file a.out a.out: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 12.2, FreeBSD-style, with debug_info, not stripped (note the absence of "interpreter ..." part). This binary runs just fine: $ lldb a.out (lldb) target create "a.out" Current executable set to '/usr/home/oleg/tmp/pg/a.out' (x86_64). (lldb) run Process 914 launching Process 914 launched: '/usr/home/oleg/tmp/pg/a.out' (x86_64) OK Process 914 exited with status =3D 0 (0x00000000) (lldb) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-250992-227>