Skip to content

Instantly share code, notes, and snippets.

@data-man
Created September 15, 2023 12:51
Show Gist options
  • Save data-man/8aa76e38dacfffa944f292a002e2226d to your computer and use it in GitHub Desktop.
Save data-man/8aa76e38dacfffa944f292a002e2226d to your computer and use it in GitHub Desktop.
libc-free C3 experiment
#!/bin/sh
c3c compile --nolibc --nostdlib main.c3 --emit-llvm --emit-asm -O0 "$@"
fn int main()
{
return 0;
}
fn void _start() @export("_start")
{
$$syscall(60, (uptr)&main); // __NR_exit
}
module std::core::builtin;
def PanicFn = fn void(String message, String file, String function, uint line);
PanicFn panic = &default_panic;
fn void default_panic(String message, String file, String function, uint line)
{
}
; ModuleID = 'main'
source_filename = "main"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%".$callstack" = type { ptr, %"char[]", %"char[]", i32, i32 }
%"char[]" = type { ptr, i64 }
$.stacktrace_init = comdat any
$.stacktrace_current = comdat any
@.stacktrace_current = weak thread_local global ptr null, comdat, align 8
@.callname = internal constant [11 x i8] c"main::main\00", align 1
@.filename = internal constant [51 x i8] c"/home/dataman/Projects/C3/-mytests/-nolibc/main.c3\00", align 1
@.callname.1 = internal constant [13 x i8] c"main::_start\00", align 1
; Function Attrs: nounwind
define i32 @main() #0 !dbg !5 {
entry:
%".$stacktrace" = alloca %".$callstack", align 8
%0 = load ptr, ptr @.stacktrace_current, align 8
store ptr %0, ptr %".$stacktrace", align 8
%1 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 1
store ptr @.callname, ptr %1, align 8
%2 = getelementptr inbounds %"char[]", ptr %1, i32 0, i32 1
store i64 10, ptr %2, align 8
%3 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 2
store ptr @.filename, ptr %3, align 8
%4 = getelementptr inbounds %"char[]", ptr %3, i32 0, i32 1
store i64 50, ptr %4, align 8
store ptr %".$stacktrace", ptr @.stacktrace_current, align 8
%5 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 3
store i32 1, ptr %5, align 8
%6 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 4
store i32 1, ptr %6, align 4
%7 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 0
store ptr null, ptr %7, align 8
%".$row" = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 4
ret i32 0, !dbg !9
}
; Function Attrs: nounwind
define void @_start() #0 !dbg !10 {
entry:
%".$stacktrace" = alloca %".$callstack", align 8
%0 = load ptr, ptr @.stacktrace_current, align 8
store ptr %0, ptr %".$stacktrace", align 8
%1 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 1
store ptr @.callname.1, ptr %1, align 8
%2 = getelementptr inbounds %"char[]", ptr %1, i32 0, i32 1
store i64 12, ptr %2, align 8
%3 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 2
store ptr @.filename, ptr %3, align 8
%4 = getelementptr inbounds %"char[]", ptr %3, i32 0, i32 1
store i64 50, ptr %4, align 8
store ptr %".$stacktrace", ptr @.stacktrace_current, align 8
%5 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 3
store i32 1, ptr %5, align 8
%6 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 4
store i32 6, ptr %6, align 4
%".$row" = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 4
%syscall = call i64 asm sideeffect alignstack "syscall", "={rax},{rax},{rdi},~{rcx},~{r11},~{memory}"(i64 60, i64 ptrtoint (ptr @main to i64)), !dbg !13
ret void, !dbg !13
}
define weak void @.stacktrace_init(ptr %0, ptr %1, i64 %2, ptr %3, i64 %4, i32 %5, i32 %6) comdat {
entry:
%7 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 0
%8 = load ptr, ptr @.stacktrace_current, align 8
store ptr %8, ptr %7, align 8
%9 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 1
%10 = getelementptr inbounds %"char[]", ptr %9, i32 0, i32 0
store ptr %1, ptr %10, align 8
%11 = getelementptr inbounds %"char[]", ptr %9, i32 0, i32 1
store i64 %2, ptr %11, align 8
%12 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 2
%13 = getelementptr inbounds %"char[]", ptr %12, i32 0, i32 0
store ptr %3, ptr %13, align 8
%14 = getelementptr inbounds %"char[]", ptr %12, i32 0, i32 1
store i64 %4, ptr %14, align 8
store ptr %0, ptr @.stacktrace_current, align 8
%15 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 3
store i32 %5, ptr %15, align 8
%16 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 4
store i32 %6, ptr %16, align 4
ret void
}
attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.dbg.cu = !{!3}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = !{i32 1, !"uwtable", i32 2}
!3 = distinct !DICompileUnit(language: DW_LANG_C11, file: !4, producer: "c3c", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false)
!4 = !DIFile(filename: "main.c3", directory: "/home/dataman/Projects/C3/-mytests/-nolibc")
!5 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !4, file: !4, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3)
!6 = !DISubroutineType(types: !7)
!7 = !{!8}
!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!9 = !DILocation(line: 3, column: 12, scope: !5)
!10 = distinct !DISubprogram(name: "_start", linkageName: "_start", scope: !4, file: !4, line: 6, type: !11, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3)
!11 = !DISubroutineType(types: !12)
!12 = !{null}
!13 = !DILocation(line: 8, column: 26, scope: !10)
.text
.file "main"
.globl main # -- Begin function main
.p2align 4, 0x90
.type main,@function
main: # @main
.Lfunc_begin0:
.file 1 "/home/dataman/Projects/C3/-mytests/-nolibc" "main.c3"
.loc 1 1 0 # main.c3:1:0
.cfi_startproc
# %bb.0: # %entry
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $48, %rsp
data16
leaq .stacktrace_current@TLSGD(%rip), %rdi
data16
data16
rex64
callq __tls_get_addr@PLT
movq (%rax), %rcx
movq %rcx, -48(%rbp)
leaq .callname(%rip), %rcx
movq %rcx, -40(%rbp)
movq $10, -32(%rbp)
leaq .filename(%rip), %rcx
movq %rcx, -24(%rbp)
movq $50, -16(%rbp)
leaq -48(%rbp), %rcx
movq %rcx, (%rax)
movl $1, -8(%rbp)
movl $1, -4(%rbp)
movq $0, -48(%rbp)
.Ltmp0:
.loc 1 3 12 prologue_end # main.c3:3:12
xorl %eax, %eax
.loc 1 3 12 epilogue_begin is_stmt 0 # main.c3:3:12
addq $48, %rsp
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Ltmp1:
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.globl _start # -- Begin function _start
.p2align 4, 0x90
.type _start,@function
_start: # @_start
.Lfunc_begin1:
.loc 1 6 0 is_stmt 1 # main.c3:6:0
.cfi_startproc
# %bb.0: # %entry
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $48, %rsp
data16
leaq .stacktrace_current@TLSGD(%rip), %rdi
data16
data16
rex64
callq __tls_get_addr@PLT
movq (%rax), %rcx
movq %rcx, -48(%rbp)
leaq .callname.1(%rip), %rcx
movq %rcx, -40(%rbp)
movq $12, -32(%rbp)
leaq .filename(%rip), %rcx
movq %rcx, -24(%rbp)
movq $50, -16(%rbp)
leaq -48(%rbp), %rcx
movq %rcx, (%rax)
movl $1, -8(%rbp)
movl $6, -4(%rbp)
.Ltmp2:
.loc 1 8 26 prologue_end # main.c3:8:26
movq main@GOTPCREL(%rip), %rdi
movl $60, %eax
#APP
syscall
#NO_APP
.loc 1 8 26 epilogue_begin is_stmt 0 # main.c3:8:26
addq $48, %rsp
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Ltmp3:
.Lfunc_end1:
.size _start, .Lfunc_end1-_start
.cfi_endproc
# -- End function
.section .text..stacktrace_init,"axG",@progbits,.stacktrace_init,comdat
.weak .stacktrace_init # -- Begin function .stacktrace_init
.p2align 4, 0x90
.type .stacktrace_init,@function
.stacktrace_init: # @.stacktrace_init
.Lfunc_begin2:
.cfi_startproc
# %bb.0: # %entry
subq $56, %rsp
.cfi_def_cfa_offset 64
movl %r9d, 12(%rsp) # 4-byte Spill
movq %r8, 16(%rsp) # 8-byte Spill
movq %rcx, 40(%rsp) # 8-byte Spill
movq %rdx, 32(%rsp) # 8-byte Spill
movq %rsi, (%rsp) # 8-byte Spill
movq %rdi, 24(%rsp) # 8-byte Spill
movl 64(%rsp), %eax
movl %eax, 52(%rsp) # 4-byte Spill
data16
leaq .stacktrace_current@TLSGD(%rip), %rdi
data16
data16
rex64
callq __tls_get_addr@PLT
movq (%rsp), %r10 # 8-byte Reload
movl 12(%rsp), %r9d # 4-byte Reload
movq 16(%rsp), %r8 # 8-byte Reload
movq 24(%rsp), %rdi # 8-byte Reload
movq 32(%rsp), %rsi # 8-byte Reload
movq 40(%rsp), %rdx # 8-byte Reload
movq %rax, %rcx
movl 52(%rsp), %eax # 4-byte Reload
movq (%rcx), %r11
movq %r11, (%rdi)
movq %r10, 8(%rdi)
movq %rsi, 16(%rdi)
movq %rdx, 24(%rdi)
movq %r8, 32(%rdi)
movq %rdi, (%rcx)
movl %r9d, 40(%rdi)
movl %eax, 44(%rdi)
addq $56, %rsp
.cfi_def_cfa_offset 8
retq
.Lfunc_end2:
.size .stacktrace_init, .Lfunc_end2-.stacktrace_init
.cfi_endproc
# -- End function
.type .stacktrace_current,@object # @.stacktrace_current
.section .tbss..stacktrace_current,"aGwT",@nobits,.stacktrace_current,comdat
.weak .stacktrace_current
.p2align 3, 0x0
.stacktrace_current:
.quad 0
.size .stacktrace_current, 8
.type .callname,@object # @.callname
.section .rodata,"a",@progbits
.callname:
.asciz "main::main"
.size .callname, 11
.type .filename,@object # @.filename
.filename:
.asciz "/home/dataman/Projects/C3/-mytests/-nolibc/main.c3"
.size .filename, 51
.type .callname.1,@object # @.callname.1
.callname.1:
.asciz "main::_start"
.size .callname.1, 13
.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
.byte 17 # DW_TAG_compile_unit
.byte 1 # DW_CHILDREN_yes
.byte 37 # DW_AT_producer
.byte 14 # DW_FORM_strp
.byte 19 # DW_AT_language
.byte 5 # DW_FORM_data2
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 16 # DW_AT_stmt_list
.byte 23 # DW_FORM_sec_offset
.byte 27 # DW_AT_comp_dir
.byte 14 # DW_FORM_strp
.ascii "\264B" # DW_AT_GNU_pubnames
.byte 25 # DW_FORM_flag_present
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 0 # DW_CHILDREN_no
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 64 # DW_AT_frame_base
.byte 24 # DW_FORM_exprloc
.byte 110 # DW_AT_linkage_name
.byte 14 # DW_FORM_strp
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 39 # DW_AT_prototyped
.byte 25 # DW_FORM_flag_present
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 3 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 0 # DW_CHILDREN_no
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 64 # DW_AT_frame_base
.byte 24 # DW_FORM_exprloc
.byte 110 # DW_AT_linkage_name
.byte 14 # DW_FORM_strp
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 39 # DW_AT_prototyped
.byte 25 # DW_FORM_flag_present
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 4 # Abbreviation Code
.byte 36 # DW_TAG_base_type
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 62 # DW_AT_encoding
.byte 11 # DW_FORM_data1
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 0 # EOM(3)
.section .debug_info,"",@progbits
.Lcu_begin0:
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
.Ldebug_info_start0:
.short 4 # DWARF version number
.long .debug_abbrev # Offset Into Abbrev. Section
.byte 8 # Address Size (in bytes)
.byte 1 # Abbrev [1] 0xb:0x5d DW_TAG_compile_unit
.long .Linfo_string0 # DW_AT_producer
.short 29 # DW_AT_language
.long .Linfo_string1 # DW_AT_name
.long .Lline_table_start0 # DW_AT_stmt_list
.long .Linfo_string2 # DW_AT_comp_dir
# DW_AT_GNU_pubnames
.quad .Lfunc_begin0 # DW_AT_low_pc
.long .Lfunc_end1-.Lfunc_begin0 # DW_AT_high_pc
.byte 2 # Abbrev [2] 0x2a:0x1d DW_TAG_subprogram
.quad .Lfunc_begin0 # DW_AT_low_pc
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.long .Linfo_string3 # DW_AT_linkage_name
.long .Linfo_string3 # DW_AT_name
.byte 1 # DW_AT_decl_file
.byte 1 # DW_AT_decl_line
# DW_AT_prototyped
.long 96 # DW_AT_type
# DW_AT_external
.byte 3 # Abbrev [3] 0x47:0x19 DW_TAG_subprogram
.quad .Lfunc_begin1 # DW_AT_low_pc
.long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.long .Linfo_string5 # DW_AT_linkage_name
.long .Linfo_string5 # DW_AT_name
.byte 1 # DW_AT_decl_file
.byte 6 # DW_AT_decl_line
# DW_AT_prototyped
# DW_AT_external
.byte 4 # Abbrev [4] 0x60:0x7 DW_TAG_base_type
.long .Linfo_string4 # DW_AT_name
.byte 5 # DW_AT_encoding
.byte 4 # DW_AT_byte_size
.byte 0 # End Of Children Mark
.Ldebug_info_end0:
.section .debug_str,"MS",@progbits,1
.Linfo_string0:
.asciz "c3c" # string offset=0
.Linfo_string1:
.asciz "main.c3" # string offset=4
.Linfo_string2:
.asciz "/home/dataman/Projects/C3/-mytests/-nolibc" # string offset=12
.Linfo_string3:
.asciz "main" # string offset=55
.Linfo_string4:
.asciz "int" # string offset=60
.Linfo_string5:
.asciz "_start" # string offset=64
.section .debug_pubnames,"",@progbits
.long .LpubNames_end0-.LpubNames_start0 # Length of Public Names Info
.LpubNames_start0:
.short 2 # DWARF Version
.long .Lcu_begin0 # Offset of Compilation Unit Info
.long 104 # Compilation Unit Length
.long 42 # DIE offset
.asciz "main" # External Name
.long 71 # DIE offset
.asciz "_start" # External Name
.long 0 # End Mark
.LpubNames_end0:
.section .debug_pubtypes,"",@progbits
.long .LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info
.LpubTypes_start0:
.short 2 # DWARF Version
.long .Lcu_begin0 # Offset of Compilation Unit Info
.long 104 # Compilation Unit Length
.long 96 # DIE offset
.asciz "int" # External Name
.long 0 # End Mark
.LpubTypes_end0:
.section ".note.GNU-stack","",@progbits
.section .debug_line,"",@progbits
.Lline_table_start0:
; ModuleID = 'std::core::builtin'
source_filename = "std::core::builtin"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%".$callstack" = type { ptr, %"char[]", %"char[]", i32, i32 }
%"char[]" = type { ptr, i64 }
$.stacktrace_init = comdat any
$.stacktrace_current = comdat any
@std.core.builtin.panic = local_unnamed_addr global ptr @std.core.builtin.default_panic, align 8
@.stacktrace_current = weak thread_local global ptr null, comdat, align 8
@.callname = internal constant [34 x i8] c"std::core::builtin::default_panic\00", align 1
@.filename = internal constant [51 x i8] c"/home/dataman/Projects/C3/-mytests/-nolibc/main.c3\00", align 1
; Function Attrs: nounwind
define void @std.core.builtin.default_panic(ptr %0, i64 %1, ptr %2, i64 %3, ptr %4, i64 %5, i32 %6) #0 !dbg !20 {
entry:
%".$stacktrace" = alloca %".$callstack", align 8
%message = alloca %"char[]", align 8
%file = alloca %"char[]", align 8
%function = alloca %"char[]", align 8
%7 = load ptr, ptr @.stacktrace_current, align 8
store ptr %7, ptr %".$stacktrace", align 8
%8 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 1
store ptr @.callname, ptr %8, align 8
%9 = getelementptr inbounds %"char[]", ptr %8, i32 0, i32 1
store i64 33, ptr %9, align 8
%10 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 2
store ptr @.filename, ptr %10, align 8
%11 = getelementptr inbounds %"char[]", ptr %10, i32 0, i32 1
store i64 50, ptr %11, align 8
store ptr %".$stacktrace", ptr @.stacktrace_current, align 8
%12 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 3
store i32 1, ptr %12, align 8
%13 = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 4
store i32 17, ptr %13, align 4
%".$row" = getelementptr inbounds %".$callstack", ptr %".$stacktrace", i32 0, i32 4
store ptr %0, ptr %message, align 8
%ptroffset = getelementptr inbounds i64, ptr %message, i64 1
store i64 %1, ptr %ptroffset, align 8
call void @llvm.dbg.declare(metadata ptr %message, metadata !22, metadata !DIExpression()), !dbg !23
store ptr %2, ptr %file, align 8
%ptroffset1 = getelementptr inbounds i64, ptr %file, i64 1
store i64 %3, ptr %ptroffset1, align 8
call void @llvm.dbg.declare(metadata ptr %file, metadata !24, metadata !DIExpression()), !dbg !25
store ptr %4, ptr %function, align 8
%ptroffset2 = getelementptr inbounds i64, ptr %function, i64 1
store i64 %5, ptr %ptroffset2, align 8
call void @llvm.dbg.declare(metadata ptr %function, metadata !26, metadata !DIExpression()), !dbg !27
ret void
}
define weak void @.stacktrace_init(ptr %0, ptr %1, i64 %2, ptr %3, i64 %4, i32 %5, i32 %6) comdat {
entry:
%7 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 0
%8 = load ptr, ptr @.stacktrace_current, align 8
store ptr %8, ptr %7, align 8
%9 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 1
%10 = getelementptr inbounds %"char[]", ptr %9, i32 0, i32 0
store ptr %1, ptr %10, align 8
%11 = getelementptr inbounds %"char[]", ptr %9, i32 0, i32 1
store i64 %2, ptr %11, align 8
%12 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 2
%13 = getelementptr inbounds %"char[]", ptr %12, i32 0, i32 0
store ptr %3, ptr %13, align 8
%14 = getelementptr inbounds %"char[]", ptr %12, i32 0, i32 1
store i64 %4, ptr %14, align 8
store ptr %0, ptr @.stacktrace_current, align 8
%15 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 3
store i32 %5, ptr %15, align 8
%16 = getelementptr inbounds %".$callstack", ptr %0, i32 0, i32 4
store i32 %6, ptr %16, align 4
ret void
}
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
!llvm.module.flags = !{!0, !1, !2}
!llvm.dbg.cu = !{!3}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = !{i32 1, !"uwtable", i32 2}
!3 = distinct !DICompileUnit(language: DW_LANG_C11, file: !4, producer: "c3c", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !5, splitDebugInlining: false)
!4 = !DIFile(filename: "main.c3", directory: "/home/dataman/Projects/C3/-mytests/-nolibc")
!5 = !{!6}
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
!7 = distinct !DIGlobalVariable(name: "panic", linkageName: "std.core.builtin.panic", scope: !4, file: !4, line: 15, type: !8, isLocal: false, isDefinition: true, align: 8)
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "PanicFn*", baseType: !9, size: 64, align: 64, dwarfAddressSpace: 0)
!9 = !DISubroutineType(types: !10)
!10 = !{null, !11, !11, !11, !19}
!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "String", scope: !4, file: !4, line: 1, baseType: !12, align: 8)
!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "char[]", size: 128, align: 64, elements: !13, runtimeLang: DW_LANG_C89, identifier: "char[]")
!13 = !{!14, !17}
!14 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !12, baseType: !15, size: 64, align: 64)
!15 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char*", baseType: !16, size: 64, align: 64, dwarfAddressSpace: 0)
!16 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)
!17 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !12, baseType: !18, size: 64, align: 64, offset: 64)
!18 = !DIBasicType(name: "ulong", size: 64, encoding: DW_ATE_unsigned)
!19 = !DIBasicType(name: "uint", size: 32, encoding: DW_ATE_unsigned)
!20 = distinct !DISubprogram(name: "default_panic", linkageName: "std.core.builtin.default_panic", scope: !4, file: !4, line: 17, type: !9, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !21)
!21 = !{}
!22 = !DILocalVariable(name: "message", arg: 1, scope: !20, file: !4, line: 17, type: !11)
!23 = !DILocation(line: 17, column: 30, scope: !20)
!24 = !DILocalVariable(name: "file", arg: 2, scope: !20, file: !4, line: 17, type: !11)
!25 = !DILocation(line: 17, column: 46, scope: !20)
!26 = !DILocalVariable(name: "function", arg: 3, scope: !20, file: !4, line: 17, type: !11)
!27 = !DILocation(line: 17, column: 59, scope: !20)
.text
.file "std::core::builtin"
.file 1 "/home/dataman/Projects/C3/-mytests/-nolibc" "main.c3"
.globl std.core.builtin.default_panic # -- Begin function std.core.builtin.default_panic
.p2align 4, 0x90
.type std.core.builtin.default_panic,@function
std.core.builtin.default_panic: # @std.core.builtin.default_panic
.Lfunc_begin0:
.cfi_startproc
# %bb.0: # %entry
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $144, %rsp
movq %r9, -144(%rbp) # 8-byte Spill
movq %r8, -136(%rbp) # 8-byte Spill
movq %rcx, -104(%rbp) # 8-byte Spill
movq %rdx, -112(%rbp) # 8-byte Spill
movq %rsi, -120(%rbp) # 8-byte Spill
movq %rdi, -128(%rbp) # 8-byte Spill
data16
leaq .stacktrace_current@TLSGD(%rip), %rdi
data16
data16
rex64
callq __tls_get_addr@PLT
movq -144(%rbp), %r9 # 8-byte Reload
movq -136(%rbp), %r8 # 8-byte Reload
movq -128(%rbp), %rdi # 8-byte Reload
movq -120(%rbp), %rsi # 8-byte Reload
movq -112(%rbp), %rdx # 8-byte Reload
movq -104(%rbp), %rcx # 8-byte Reload
movq (%rax), %r10
movq %r10, -48(%rbp)
leaq .callname(%rip), %r10
movq %r10, -40(%rbp)
movq $33, -32(%rbp)
leaq .filename(%rip), %r10
movq %r10, -24(%rbp)
movq $50, -16(%rbp)
leaq -48(%rbp), %r10
movq %r10, (%rax)
movl $1, -8(%rbp)
movl $17, -4(%rbp)
movq %rdi, -64(%rbp)
movq %rsi, -56(%rbp)
movq %rdx, -80(%rbp)
movq %rcx, -72(%rbp)
movq %r8, -96(%rbp)
movq %r9, -88(%rbp)
addq $144, %rsp
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Lfunc_end0:
.size std.core.builtin.default_panic, .Lfunc_end0-std.core.builtin.default_panic
.cfi_endproc
# -- End function
.section .text..stacktrace_init,"axG",@progbits,.stacktrace_init,comdat
.weak .stacktrace_init # -- Begin function .stacktrace_init
.p2align 4, 0x90
.type .stacktrace_init,@function
.stacktrace_init: # @.stacktrace_init
.Lfunc_begin1:
.cfi_startproc
# %bb.0: # %entry
subq $56, %rsp
.cfi_def_cfa_offset 64
movl %r9d, 12(%rsp) # 4-byte Spill
movq %r8, 16(%rsp) # 8-byte Spill
movq %rcx, 40(%rsp) # 8-byte Spill
movq %rdx, 32(%rsp) # 8-byte Spill
movq %rsi, (%rsp) # 8-byte Spill
movq %rdi, 24(%rsp) # 8-byte Spill
movl 64(%rsp), %eax
movl %eax, 52(%rsp) # 4-byte Spill
data16
leaq .stacktrace_current@TLSGD(%rip), %rdi
data16
data16
rex64
callq __tls_get_addr@PLT
movq (%rsp), %r10 # 8-byte Reload
movl 12(%rsp), %r9d # 4-byte Reload
movq 16(%rsp), %r8 # 8-byte Reload
movq 24(%rsp), %rdi # 8-byte Reload
movq 32(%rsp), %rsi # 8-byte Reload
movq 40(%rsp), %rdx # 8-byte Reload
movq %rax, %rcx
movl 52(%rsp), %eax # 4-byte Reload
movq (%rcx), %r11
movq %r11, (%rdi)
movq %r10, 8(%rdi)
movq %rsi, 16(%rdi)
movq %rdx, 24(%rdi)
movq %r8, 32(%rdi)
movq %rdi, (%rcx)
movl %r9d, 40(%rdi)
movl %eax, 44(%rdi)
addq $56, %rsp
.cfi_def_cfa_offset 8
retq
.Lfunc_end1:
.size .stacktrace_init, .Lfunc_end1-.stacktrace_init
.cfi_endproc
# -- End function
.type std.core.builtin.panic,@object # @std.core.builtin.panic
.data
.globl std.core.builtin.panic
.p2align 3, 0x0
std.core.builtin.panic:
.quad std.core.builtin.default_panic
.size std.core.builtin.panic, 8
.type .stacktrace_current,@object # @.stacktrace_current
.section .tbss..stacktrace_current,"aGwT",@nobits,.stacktrace_current,comdat
.weak .stacktrace_current
.p2align 3, 0x0
.stacktrace_current:
.quad 0
.size .stacktrace_current, 8
.type .callname,@object # @.callname
.section .rodata,"a",@progbits
.callname:
.asciz "std::core::builtin::default_panic"
.size .callname, 34
.type .filename,@object # @.filename
.filename:
.asciz "/home/dataman/Projects/C3/-mytests/-nolibc/main.c3"
.size .filename, 51
.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
.byte 17 # DW_TAG_compile_unit
.byte 1 # DW_CHILDREN_yes
.byte 37 # DW_AT_producer
.byte 14 # DW_FORM_strp
.byte 19 # DW_AT_language
.byte 5 # DW_FORM_data2
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 16 # DW_AT_stmt_list
.byte 23 # DW_FORM_sec_offset
.byte 27 # DW_AT_comp_dir
.byte 14 # DW_FORM_strp
.ascii "\264B" # DW_AT_GNU_pubnames
.byte 25 # DW_FORM_flag_present
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
.byte 52 # DW_TAG_variable
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.ascii "\210\001" # DW_AT_alignment
.byte 15 # DW_FORM_udata
.byte 110 # DW_AT_linkage_name
.byte 14 # DW_FORM_strp
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 3 # Abbreviation Code
.byte 15 # DW_TAG_pointer_type
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 51 # DW_AT_address_class
.byte 6 # DW_FORM_data4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 4 # Abbreviation Code
.byte 21 # DW_TAG_subroutine_type
.byte 1 # DW_CHILDREN_yes
.byte 39 # DW_AT_prototyped
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 5 # Abbreviation Code
.byte 5 # DW_TAG_formal_parameter
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 6 # Abbreviation Code
.byte 22 # DW_TAG_typedef
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 7 # Abbreviation Code
.byte 19 # DW_TAG_structure_type
.byte 1 # DW_CHILDREN_yes
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.ascii "\346\177" # DW_AT_APPLE_runtime_class
.byte 11 # DW_FORM_data1
.ascii "\210\001" # DW_AT_alignment
.byte 15 # DW_FORM_udata
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 8 # Abbreviation Code
.byte 13 # DW_TAG_member
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.ascii "\210\001" # DW_AT_alignment
.byte 15 # DW_FORM_udata
.byte 56 # DW_AT_data_member_location
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 9 # Abbreviation Code
.byte 36 # DW_TAG_base_type
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 62 # DW_AT_encoding
.byte 11 # DW_FORM_data1
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 10 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 0 # DW_CHILDREN_no
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 64 # DW_AT_frame_base
.byte 24 # DW_FORM_exprloc
.byte 110 # DW_AT_linkage_name
.byte 14 # DW_FORM_strp
.byte 3 # DW_AT_name
.byte 14 # DW_FORM_strp
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 39 # DW_AT_prototyped
.byte 25 # DW_FORM_flag_present
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 0 # EOM(3)
.section .debug_info,"",@progbits
.Lcu_begin0:
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
.Ldebug_info_start0:
.short 4 # DWARF version number
.long .debug_abbrev # Offset Into Abbrev. Section
.byte 8 # Address Size (in bytes)
.byte 1 # Abbrev [1] 0xb:0xb8 DW_TAG_compile_unit
.long .Linfo_string0 # DW_AT_producer
.short 29 # DW_AT_language
.long .Linfo_string1 # DW_AT_name
.long .Lline_table_start0 # DW_AT_stmt_list
.long .Linfo_string2 # DW_AT_comp_dir
# DW_AT_GNU_pubnames
.quad .Lfunc_begin0 # DW_AT_low_pc
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
.byte 2 # Abbrev [2] 0x2a:0x10 DW_TAG_variable
.long .Linfo_string3 # DW_AT_name
.long 58 # DW_AT_type
# DW_AT_external
.byte 1 # DW_AT_decl_file
.byte 15 # DW_AT_decl_line
.byte 1 # DW_AT_alignment
.long .Linfo_string13 # DW_AT_linkage_name
.byte 3 # Abbrev [3] 0x3a:0xd DW_TAG_pointer_type
.long 71 # DW_AT_type
.long .Linfo_string12 # DW_AT_name
.long 0 # DW_AT_address_class
.byte 4 # Abbrev [4] 0x47:0x16 DW_TAG_subroutine_type
# DW_AT_prototyped
.byte 5 # Abbrev [5] 0x48:0x5 DW_TAG_formal_parameter
.long 93 # DW_AT_type
.byte 5 # Abbrev [5] 0x4d:0x5 DW_TAG_formal_parameter
.long 93 # DW_AT_type
.byte 5 # Abbrev [5] 0x52:0x5 DW_TAG_formal_parameter
.long 93 # DW_AT_type
.byte 5 # Abbrev [5] 0x57:0x5 DW_TAG_formal_parameter
.long 162 # DW_AT_type
.byte 0 # End Of Children Mark
.byte 6 # Abbrev [6] 0x5d:0xb DW_TAG_typedef
.long 104 # DW_AT_type
.long .Linfo_string10 # DW_AT_name
.byte 1 # DW_AT_decl_file
.byte 1 # DW_AT_decl_line
.byte 7 # Abbrev [7] 0x68:0x1f DW_TAG_structure_type
.long .Linfo_string9 # DW_AT_name
.byte 16 # DW_AT_byte_size
.byte 1 # DW_AT_APPLE_runtime_class
.byte 8 # DW_AT_alignment
.byte 8 # Abbrev [8] 0x70:0xb DW_TAG_member
.long .Linfo_string4 # DW_AT_name
.long 135 # DW_AT_type
.byte 8 # DW_AT_alignment
.byte 0 # DW_AT_data_member_location
.byte 8 # Abbrev [8] 0x7b:0xb DW_TAG_member
.long .Linfo_string7 # DW_AT_name
.long 155 # DW_AT_type
.byte 8 # DW_AT_alignment
.byte 8 # DW_AT_data_member_location
.byte 0 # End Of Children Mark
.byte 3 # Abbrev [3] 0x87:0xd DW_TAG_pointer_type
.long 148 # DW_AT_type
.long .Linfo_string6 # DW_AT_name
.long 0 # DW_AT_address_class
.byte 9 # Abbrev [9] 0x94:0x7 DW_TAG_base_type
.long .Linfo_string5 # DW_AT_name
.byte 8 # DW_AT_encoding
.byte 1 # DW_AT_byte_size
.byte 9 # Abbrev [9] 0x9b:0x7 DW_TAG_base_type
.long .Linfo_string8 # DW_AT_name
.byte 7 # DW_AT_encoding
.byte 8 # DW_AT_byte_size
.byte 9 # Abbrev [9] 0xa2:0x7 DW_TAG_base_type
.long .Linfo_string11 # DW_AT_name
.byte 7 # DW_AT_encoding
.byte 4 # DW_AT_byte_size
.byte 10 # Abbrev [10] 0xa9:0x19 DW_TAG_subprogram
.quad .Lfunc_begin0 # DW_AT_low_pc
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.long .Linfo_string14 # DW_AT_linkage_name
.long .Linfo_string15 # DW_AT_name
.byte 1 # DW_AT_decl_file
.byte 17 # DW_AT_decl_line
# DW_AT_prototyped
# DW_AT_external
.byte 0 # End Of Children Mark
.Ldebug_info_end0:
.section .debug_str,"MS",@progbits,1
.Linfo_string0:
.asciz "c3c" # string offset=0
.Linfo_string1:
.asciz "main.c3" # string offset=4
.Linfo_string2:
.asciz "/home/dataman/Projects/C3/-mytests/-nolibc" # string offset=12
.Linfo_string3:
.asciz "panic" # string offset=55
.Linfo_string4:
.asciz "ptr" # string offset=61
.Linfo_string5:
.asciz "char" # string offset=65
.Linfo_string6:
.asciz "char*" # string offset=70
.Linfo_string7:
.asciz "len" # string offset=76
.Linfo_string8:
.asciz "ulong" # string offset=80
.Linfo_string9:
.asciz "char[]" # string offset=86
.Linfo_string10:
.asciz "String" # string offset=93
.Linfo_string11:
.asciz "uint" # string offset=100
.Linfo_string12:
.asciz "PanicFn*" # string offset=105
.Linfo_string13:
.asciz "std.core.builtin.panic" # string offset=114
.Linfo_string14:
.asciz "std.core.builtin.default_panic" # string offset=137
.Linfo_string15:
.asciz "default_panic" # string offset=168
.section .debug_pubnames,"",@progbits
.long .LpubNames_end0-.LpubNames_start0 # Length of Public Names Info
.LpubNames_start0:
.short 2 # DWARF Version
.long .Lcu_begin0 # Offset of Compilation Unit Info
.long 195 # Compilation Unit Length
.long 42 # DIE offset
.asciz "panic" # External Name
.long 169 # DIE offset
.asciz "default_panic" # External Name
.long 0 # End Mark
.LpubNames_end0:
.section .debug_pubtypes,"",@progbits
.long .LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info
.LpubTypes_start0:
.short 2 # DWARF Version
.long .Lcu_begin0 # Offset of Compilation Unit Info
.long 195 # Compilation Unit Length
.long 58 # DIE offset
.asciz "PanicFn*" # External Name
.long 93 # DIE offset
.asciz "String" # External Name
.long 104 # DIE offset
.asciz "char[]" # External Name
.long 135 # DIE offset
.asciz "char*" # External Name
.long 148 # DIE offset
.asciz "char" # External Name
.long 155 # DIE offset
.asciz "ulong" # External Name
.long 162 # DIE offset
.asciz "uint" # External Name
.long 0 # End Mark
.LpubTypes_end0:
.section ".note.GNU-stack","",@progbits
.section .debug_line,"",@progbits
.Lline_table_start0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment