[Bug 250992] Binaries produced by clang -pg on x86-64 always crash in ld-elf.so.1
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Mon Nov 9 20:40:52 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250992
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 at FreeBSD.org
Reporter: oleg.derevenetz at 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 = 'a.out', stop reason = signal SIGSEGV: invalid address
(fault address: 0x0)
frame #0: 0x00000008002a3ab0
-> 0x8002a3ab0: movq (%r15), %rdx
0x8002a3ab3: cmpq $0x6fffffef, %rdx ; imm = 0x6FFFFFEF
0x8002a3aba: jg 0x8002a3b10
0x8002a3abc: cmpq $0x21, %rdx
(lldb) disassemble
-> 0x8002a3ab0: movq (%r15), %rdx
0x8002a3ab3: cmpq $0x6fffffef, %rdx ; imm = 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 = 0 (0x00000000)
(lldb)
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list