Skip to content

Instantly share code, notes, and snippets.

@andrewrk

andrewrk/objdump Secret

Forked from vegard/pointers.zig
Last active February 11, 2018 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewrk/7ef02ef969147f457671176ec9ebd408 to your computer and use it in GitHub Desktop.
Save andrewrk/7ef02ef969147f457671176ec9ebd408 to your computer and use it in GitHub Desktop.
zig-cache/pointers.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <panic>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 89 7d f8 mov %rdi,-0x8(%rbp)
8: eb fe jmp 8 <panic+0x8>
a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
0000000000000010 <get_pointer>:
10: 55 push %rbp
11: 48 89 e5 mov %rsp,%rbp
14: 48 8d 05 00 00 00 00 lea 0x0(%rip),%rax # 1b <get_pointer+0xb>
17: R_X86_64_PC32 .data-0x4
1b: 5d pop %rbp
1c: c3 retq
Disassembly of section .data:
0000000000000000 <x>:
0: d2 04 00 rolb %cl,(%rax,%rax,1)
3: 00 00 add %al,(%rax)
5: 00 00 add %al,(%rax)
...
0000000000000008 <x_ptr>:
...
8: R_X86_64_64 .data
Disassembly of section .data.rel.ro:
0000000000000000 <__unnamed_1>:
...
0: R_X86_64_64 .data
; ModuleID = 'pointers'
source_filename = "pointers"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"[]u8" = type { i8*, i64 }
%StackTrace = type { i64, %"[]usize" }
%"[]usize" = type { i64*, i64 }
@x = internal unnamed_addr global i32 1234, align 4
@x_ptr = unnamed_addr global i32* @x, align 8
@0 = internal unnamed_addr constant i32* @x, align 8
; Function Attrs: nobuiltin noreturn nounwind
define internal fastcc void @panic(%"[]u8"* byval nonnull readonly, %StackTrace*) unnamed_addr #0 !dbg !8 {
Entry:
%error_return_trace = alloca %StackTrace*, align 8
call void @llvm.dbg.declare(metadata %"[]u8"* %0, metadata !33, metadata !36), !dbg !37
store %StackTrace* %1, %StackTrace** %error_return_trace, align 8
call void @llvm.dbg.declare(metadata %StackTrace** %error_return_trace, metadata !34, metadata !36), !dbg !38
br label %WhileCond, !dbg !39
WhileCond: ; preds = %WhileCond, %Entry
br label %WhileCond, !dbg !39
}
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
; Function Attrs: nobuiltin nounwind
define internal fastcc nonnull i32* @get_pointer() unnamed_addr #2 !dbg !42 {
Entry:
ret i32* @x, !dbg !48
}
; Function Attrs: nounwind
declare void @llvm.stackprotector(i8*, i8**) #3
attributes #0 = { nobuiltin noreturn nounwind "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
attributes #1 = { nounwind readnone speculatable }
attributes #2 = { nobuiltin nounwind "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "zig 0.1.1.e743b30b", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
!2 = !DIFile(filename: "pointers", directory: ".")
!3 = !{!4}
!4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "error", baseType: !5, size: 16, align: 16, elements: !6)
!5 = !DIBasicType(name: "u16", size: 16, encoding: DW_ATE_unsigned)
!6 = !{!7}
!7 = !DIEnumerator(name: "(none)", value: 0)
!8 = distinct !DISubprogram(name: "panic", scope: !9, file: !9, line: 9, type: !10, isLocal: true, isDefinition: true, scopeLine: 9, isOptimized: false, unit: !1, variables: !32)
!9 = !DIFile(filename: "pointers.zig", directory: "/home/andy/downloads/zig/build")
!10 = !DISubroutineType(types: !11)
!11 = !{!12, !13, !21}
!12 = !DIBasicType(name: "void", encoding: DW_ATE_unsigned)
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&[]const u8", baseType: !14, size: 64, align: 64)
!14 = !DICompositeType(tag: DW_TAG_structure_type, name: "[]u8", size: 128, align: 64, elements: !15)
!15 = !{!16, !19}
!16 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !14, baseType: !17, size: 64, align: 64)
!17 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&u8", baseType: !18, size: 64, align: 64)
!18 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned_char)
!19 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !14, baseType: !20, size: 64, align: 64, offset: 64)
!20 = !DIBasicType(name: "usize", size: 64, encoding: DW_ATE_unsigned)
!21 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&StackTrace", baseType: !22, size: 64, align: 64)
!22 = !DICompositeType(tag: DW_TAG_structure_type, name: "StackTrace", scope: !23, file: !23, line: 1, size: 192, align: 192, elements: !24)
!23 = !DIFile(filename: "builtin.zig", directory: "/home/andy/downloads/zig/build/zig-cache")
!24 = !{!25, !26}
!25 = !DIDerivedType(tag: DW_TAG_member, name: "index", scope: !22, file: !23, line: 2, baseType: !20, size: 64, align: 64)
!26 = !DIDerivedType(tag: DW_TAG_member, name: "instruction_addresses", scope: !22, file: !23, line: 3, baseType: !27, size: 128, align: 128, offset: 64)
!27 = !DICompositeType(tag: DW_TAG_structure_type, name: "[]usize", size: 128, align: 64, elements: !28)
!28 = !{!29, !31}
!29 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !27, baseType: !30, size: 64, align: 64)
!30 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&usize", baseType: !20, size: 64, align: 64)
!31 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !27, baseType: !20, size: 64, align: 64, offset: 64)
!32 = !{!33, !34}
!33 = !DILocalVariable(name: "msg", arg: 1, scope: !8, file: !9, line: 9, type: !14)
!34 = !DILocalVariable(name: "error_return_trace", arg: 2, scope: !35, file: !9, line: 9, type: !21)
!35 = distinct !DILexicalBlock(scope: !8, file: !9, line: 9, column: 14)
!36 = !DIExpression()
!37 = !DILocation(line: 9, column: 14, scope: !8)
!38 = !DILocation(line: 9, column: 31, scope: !35)
!39 = !DILocation(line: 10, column: 5, scope: !40)
!40 = distinct !DILexicalBlock(scope: !41, file: !9, line: 9, column: 82)
!41 = distinct !DILexicalBlock(scope: !35, file: !9, line: 9, column: 31)
!42 = distinct !DISubprogram(name: "get_pointer", scope: !9, file: !9, line: 4, type: !43, isLocal: true, isDefinition: true, scopeLine: 4, isOptimized: false, unit: !1, variables: !47)
!43 = !DISubroutineType(types: !44)
!44 = !{!45}
!45 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&i32", baseType: !46, size: 64, align: 64)
!46 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
!47 = !{}
!48 = !DILocation(line: 5, column: 5, scope: !49)
!49 = distinct !DILexicalBlock(scope: !42, file: !9, line: 4, column: 23)
var x: i32 = 1234;
export var x_ptr = get_pointer();
fn get_pointer() &i32 {
return &x;
}
const builtin = @import("builtin");
pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {
while (true) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment