Skip to content

Instantly share code, notes, and snippets.

@jld
jld / gist:5110554
Created March 7, 2013 18:38
Go home, LLVM syntax. You're drunk.
@const = constant
{ { { { i64, <{ { { i8*, i64 } } }>, [0 x i8] }, i8, i8 },
{ i64, <{ { { void ({}*, { i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*)*,
{ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* } } }>,
[8 x i8] } },
{ { { i64, <{ { { i8*, i64 } } }>, [0 x i8] }, i8, i8 },
{ i64, <{ { { void ({}*, { i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*)*,
{ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* } } }>,
[8 x i8] } } }
{ { { { i64, <{ { { i8*, i64 } } }>, [0 x i8] }, i8, i8 },
struct S(&static/[int]);
pub const C0: S = S([3]);
pub const C1: int = C0[0];
@jld
jld / gist:5127759
Last active December 14, 2015 18:09
Hello, Assembly World
#ifdef __ELF__
#define SYMBOL_THING ""
#else
#define SYMBOL_THING "_"
#endif
int main() {
int r;
asm volatile(
".pushsection .rodata\n"
@jld
jld / gist:5172035
Created March 15, 2013 18:40
The difference between a libjpeg that works and a libjpeg that blackscreens my FirefoxOS dev phone. WTF, binutils.
62c62
< LOAD 0x037000 0x00037000 0x00037000 0x00460 0x00478 RW 0x1000
---
> LOAD 0x037000 0x0006e000 0x00037000 0x00460 0x00478 RW 0x1000
71c71
< 02 .init_array .fini_array .data.rel.ro .dynamic .got .data .bss
---
> 02
#!/usr/bin/env python
import json, sys
prof = json.load(sys.stdin)
for thread in prof['profileJSON']['threads']:
raw = thread['samples']
low = [raw[i]['time'] - raw[i-1]['time'] for i in xrange(1, len(raw))]
while True:
oldlen = len(low)
avg = sum(low) / oldlen
rust: task failed at 'assertion failed: !bcx.ccx().maps.moves_map.contains(&arg_expr.id)', /home/jld/src/rust/src/librustc/middle/trans/callee.rs:735
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7f0d58827b0b]
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(+0x2cb39)[0x7f0d58838b39]
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(upcall_fail+0x1a0)[0x7f0d58829ab0]
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so(+0x11298b)[0x7f0d5be1c98b]
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so(+0x112932)[0x7f0d5be1c932]
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so(_ZN3sys12begin_unwind16_701b8ec61f97ead6_07preE+0x71)[0x7f0d5bd62041]
/usr/local/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/
@jld
jld / gist:5703692
Created June 4, 2013 05:00
In which Rust code is evaluated over IRC, and monomorphize.rs has a bad day.
21:48 < jld> rusti: struct S<T>{i:u8,t:T} impl<T> S<T>{fn unwrap(self)->T{self.t}} struct A((u32, u32)); struct
B(u64); static Ca: S<A> = S{i:0,t:A((13, 104))}; static Cb: S<B> = S{i:0,t:B(31337)};
(Ca.unwrap(), Cb.unwrap())
21:48 -rusti:#rust- ({__field__: (13, 104)}, {__field__: 134591390154752})
21:49 < jld> rusti: struct S<T>{i:u8,t:T} impl<T> S<T>{fn unwrap(self)->T{self.t}} struct A((u32, u32)); struct
B(u64); static Ca: S<A> = S{i:0,t:A((13, 104))}; static Cb: S<B> = S{i:0,t:B(31337)}; Cb.unwrap()
21:49 -rusti:#rust- {__field__: 31337}
21:57 < jld> rusti: struct S<T>{i:u8,t:T} impl<T> S<T>{fn unwrap(self)->T{self.t}} struct A((u32, u32)); struct
@jld
jld / gist:5812230
Last active December 18, 2015 16:29
Obj.magic: not even once.
(*
* Uses Obj.magic at 'a -> int, once; the rest is safe. When compiled with
* ocamlopt, should fail with a segmentation fault or bus error at some point,
* details depending on CPU.
*)
open Printf;;
let () =
let x = [|0|] in
let xi : int = Obj.magic x in
printf "xi = %d\n%!" xi;
@jld
jld / gist:5854799
Created June 24, 2013 23:54
Linux kernel config diff between geeksphone keon and peak
--- arch/arm/configs/C8666_defconfig 2013-06-21 12:16:58.431905281 -0700
+++ /proc/self/fd/15 2013-06-24 16:53:35.741254412 -0700
@@ -1,6 +1,6 @@
#
# Automatically generated make config: don't edit
-# Linux/arm 3.0.8 Kernel Configuration
+# Linux/arm 3.0.21 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@jld
jld / gist:5864000
Created June 26, 2013 01:24
In which there are regressions. (But are they mine?)
[5616| 39| 0| 662] 100% ==========================================>|5730.8s
REGRESSIONS
ecma_5/extensions/function-definition-with.js
ecma_5/extensions/proxy-enumeration.js
ecma_5/extensions/cross-global-eval-is-indirect.js
ecma_5/extensions/preventExtensions-cross-global.js
ecma_5/extensions/cross-global-getPrototypeOf.js
ecma_5/Global/cross-global-implicit-this.js
ecma_5/Object/freeze-global-eval-const.js
ecma_5/RegExp/regress-617935.js