Skip to content

Instantly share code, notes, and snippets.

@withzombies
Last active February 7, 2016 19:12
Show Gist options
  • Save withzombies/27c3ce6489c4489d0cf5 to your computer and use it in GitHub Desktop.
Save withzombies/27c3ce6489c4489d0cf5 to your computer and use it in GitHub Desktop.
-fembed-bitcode
$ /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -o test test.c -fembed-bitcode
$ otool -l test | grep -A 20 -i llvm
segname __LLVM
vmaddr 0x0000000100002000
vmsize 0x0000000000002000
fileoff 8192
filesize 8192
maxprot 0x00000007
initprot 0x00000003
nsects 1
flags 0x4
Section
sectname __bundle
segname __LLVM
addr 0x0000000100002000
size 0x0000000000001255
offset 8192
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
$ segedit file --extract __LLVM __bundle test.bc.xar
$ file test.bc.xar
test.bc.xar: xar archive - version 1
$ xar -x -f test.bc.xar
$ file 1
1: LLVM bit-code object x86_64
$ llvm-dis 1
$ head 1.ll
; ModuleID = '1'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
@.str = private unnamed_addr constant [26 x i8] c"test2 : made it this far\0A\00", align 1
@.str1 = private unnamed_addr constant [16 x i8] c"mast_inject_all\00", section "llvm.metadata"
@.str2 = private unnamed_addr constant [7 x i8] c"test.c\00", section "llvm.metadata"
@.str3 = private unnamed_addr constant [7 x i8] c"First\0A\00", align 1
@.str4 = private unnamed_addr constant [8 x i8] c"Second\0A\00", align 1
@.str5 = private unnamed_addr constant [7 x i8] c"Third\0A\00", align 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment