Skip to content

Instantly share code, notes, and snippets.

@jeshan
Created May 27, 2021 17:36
Show Gist options
  • Save jeshan/e81bfc8fc34d79b692416528486f68ce to your computer and use it in GitHub Desktop.
Save jeshan/e81bfc8fc34d79b692416528486f68ce to your computer and use it in GitHub Desktop.
; ModuleID = 'crt1.o'
source_filename = "crt/crt1.c"
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-alpine-linux-musl"
module asm ".text "
module asm ".global _start "
module asm "_start: "
module asm "\09xor %rbp,%rbp "
module asm "\09mov %rsp,%rdi "
module asm ".weak _DYNAMIC "
module asm ".hidden _DYNAMIC "
module asm "\09lea _DYNAMIC(%rip),%rsi "
module asm "\09andq $-16,%rsp "
module asm "\09call _start_c "
; Function Attrs: noinline nounwind optnone
define dso_local void @_start_c(i64* %0) #0 !dbg !13 {
%2 = alloca i64*, align 8
%3 = alloca i32, align 4
%4 = alloca i8**, align 8
store i64* %0, i64** %2, align 8
call void @llvm.dbg.declare(metadata i64** %2, metadata !18, metadata !DIExpression()), !dbg !19
call void @llvm.dbg.declare(metadata i32* %3, metadata !20, metadata !DIExpression()), !dbg !22
%5 = load i64*, i64** %2, align 8, !dbg !23
%6 = getelementptr inbounds i64, i64* %5, i64 0, !dbg !23
%7 = load i64, i64* %6, align 8, !dbg !23
%8 = trunc i64 %7 to i32, !dbg !23
store i32 %8, i32* %3, align 4, !dbg !22
call void @llvm.dbg.declare(metadata i8*** %4, metadata !24, metadata !DIExpression()), !dbg !28
%9 = load i64*, i64** %2, align 8, !dbg !29
%10 = getelementptr inbounds i64, i64* %9, i64 1, !dbg !30
%11 = bitcast i64* %10 to i8*, !dbg !31
%12 = bitcast i8* %11 to i8**, !dbg !31
store i8** %12, i8*** %4, align 8, !dbg !28
%13 = load i32, i32* %3, align 4, !dbg !32
%14 = load i8**, i8*** %4, align 8, !dbg !33
%15 = call i32 @__libc_start_main(i32 (...)* @main, i32 %13, i8** %14, void (...)* @_init, void (...)* @_fini, void (...)* null) #3, !dbg !34
ret void, !dbg !35
}
; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
declare i32 @__libc_start_main(i32 (...)*, i32, i8**, void (...)*, void (...)*, void (...)*) #2
declare i32 @main(...) #2
declare extern_weak void @_init(...) #2
declare extern_weak void @_fini(...) #2
attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }
attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-builtins" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nobuiltin "no-builtins" }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!5, !6, !7, !8, !9, !10, !11}
!llvm.ident = !{!12}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Alpine clang version 10.0.1 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "crt/crt1.c", directory: "/app/aports-3.13-stable/main/musl/src/v1.2.2")
!2 = !{}
!3 = !{!4}
!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
!5 = !{i32 7, !"Dwarf Version", i32 4}
!6 = !{i32 2, !"Debug Info Version", i32 3}
!7 = !{i32 1, !"wchar_size", i32 4}
!8 = !{i32 7, !"PIC Level", i32 2}
!9 = !{i32 7, !"PIE Level", i32 2}
!10 = !{i32 1, !"ThinLTO", i32 0}
!11 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
!12 = !{!"Alpine clang version 10.0.1 "}
!13 = distinct !DISubprogram(name: "_start_c", scope: !1, file: !1, line: 14, type: !14, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!14 = !DISubroutineType(types: !15)
!15 = !{null, !16}
!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64)
!17 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
!18 = !DILocalVariable(name: "p", arg: 1, scope: !13, file: !1, line: 14, type: !16)
!19 = !DILocation(line: 14, column: 21, scope: !13)
!20 = !DILocalVariable(name: "argc", scope: !13, file: !1, line: 16, type: !21)
!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!22 = !DILocation(line: 16, column: 6, scope: !13)
!23 = !DILocation(line: 16, column: 13, scope: !13)
!24 = !DILocalVariable(name: "argv", scope: !13, file: !1, line: 17, type: !25)
!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !26, size: 64)
!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 64)
!27 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!28 = !DILocation(line: 17, column: 9, scope: !13)
!29 = !DILocation(line: 17, column: 25, scope: !13)
!30 = !DILocation(line: 17, column: 26, scope: !13)
!31 = !DILocation(line: 17, column: 16, scope: !13)
!32 = !DILocation(line: 18, column: 26, scope: !13)
!33 = !DILocation(line: 18, column: 32, scope: !13)
!34 = !DILocation(line: 18, column: 2, scope: !13)
!35 = !DILocation(line: 19, column: 1, scope: !13)
^0 = module: (path: "crt1.o", hash: (0, 0, 0, 0, 0))
^1 = gv: (name: "_init") ; guid = 3788571788581730100
^2 = gv: (name: "_fini") ; guid = 12847049297108431452
^3 = gv: (name: "_start_c", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 1, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 18, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0), calls: ((callee: ^5)), refs: (^6, ^1, ^2)))) ; guid = 12876309325424598481
^4 = gv: (name: "llvm.dbg.declare") ; guid = 13513223491971101989
^5 = gv: (name: "__libc_start_main") ; guid = 13749316503500873128
^6 = gv: (name: "main") ; guid = 15822663052811949562
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment