Skip to content

Instantly share code, notes, and snippets.

@TimNN

TimNN/bad.ll Secret

Created November 3, 2016 20:53
Show Gist options
  • Save TimNN/a9cc563fa8dffd40a5192b510509af1b to your computer and use it in GitHub Desktop.
Save TimNN/a9cc563fa8dffd40a5192b510509af1b to your computer and use it in GitHub Desktop.
; ModuleID = 'farm.cgu-0.rs'
source_filename = "farm.cgu-0.rs"
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7-unknown-linux-gnueabihf"
; Function Attrs: inlinehint uwtable
define internal zeroext i1 @"_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E"(float* noalias readonly dereferenceable(4), float* noalias readonly dereferenceable(4)) unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%2 = load float, float* %0
%3 = load float, float* %1
%4 = fcmp oeq float %2, %3
br label %bb1
bb1: ; preds = %start
ret i1 %4
}
; Function Attrs: inlinehint uwtable
define internal zeroext i1 @"_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE"(float* noalias readonly dereferenceable(4), float* noalias readonly dereferenceable(4)) unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%2 = load float, float* %0
%3 = load float, float* %1
%4 = fcmp une float %2, %3
br label %bb1
bb1: ; preds = %start
ret i1 %4
}
; Function Attrs: uwtable
define internal i32 @_ZN4farm3bar17ha079dee3d7efd2c9E(i32, i8**) unnamed_addr #1 {
entry-block:
%return = alloca i32
%tmp_ret = alloca float
br label %start
start: ; preds = %entry-block
%2 = call float @llvm.powi.f32(float 1.234500e+04, i32 0)
store float %2, float* %tmp_ret
%3 = load float, float* %tmp_ret
br label %bb1
bb1: ; preds = %start
%4 = fcmp oeq float %3, 1.000000e+00
br i1 %4, label %bb2, label %bb3
bb2: ; preds = %bb1
store i32 0, i32* %return
br label %bb4
bb3: ; preds = %bb1
store i32 1, i32* %return
br label %bb4
bb4: ; preds = %bb2, %bb3
%5 = load i32, i32* %return
ret i32 %5
}
; Function Attrs: nounwind readnone
declare float @llvm.powi.f32(float, i32) #2
define i32 @main(i32, i8**) unnamed_addr {
top:
%2 = call i32 @_ZN4farm3bar17ha079dee3d7efd2c9E(i32 %0, i8** %1)
ret i32 %2
}
attributes #0 = { inlinehint uwtable }
attributes #1 = { uwtable }
attributes #2 = { nounwind readnone }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}
.text
.syntax unified
.eabi_attribute 67, "2.09"
.eabi_attribute 6, 10
.eabi_attribute 7, 65
.eabi_attribute 8, 1
.eabi_attribute 9, 2
.fpu neon
.eabi_attribute 15, 1
.eabi_attribute 16, 1
.eabi_attribute 17, 2
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 34, 1
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 28, 1
.eabi_attribute 38, 1
.eabi_attribute 14, 0
.file "farm.cgu-0.rs"
.section ".text._ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E","ax",%progbits
.p2align 2
.type _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E,%function
_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E:
.fnstart
.pad #12
sub sp, sp, #12
str r0, [sp, #8]
str r1, [sp, #4]
b .LBB0_1
.LBB0_1:
ldr r0, [sp, #8]
vldr s0, [r0]
ldr r1, [sp, #4]
vldr s2, [r1]
vcmpe.f32 s0, s2
vmrs APSR_nzcv, fpscr
movw r2, #0
moveq r2, #1
str r2, [sp]
ldr r0, [sp]
and r0, r0, #1
add sp, sp, #12
bx lr
.Lfunc_end0:
.size _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E, .Lfunc_end0-_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E
.fnend
.section ".text._ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE","ax",%progbits
.p2align 2
.type _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE,%function
_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE:
.fnstart
.pad #12
sub sp, sp, #12
str r0, [sp, #8]
str r1, [sp, #4]
b .LBB1_1
.LBB1_1:
ldr r0, [sp, #8]
vldr s0, [r0]
ldr r1, [sp, #4]
vldr s2, [r1]
vcmpe.f32 s0, s2
vmrs APSR_nzcv, fpscr
movw r2, #0
movne r2, #1
str r2, [sp]
ldr r0, [sp]
and r0, r0, #1
add sp, sp, #12
bx lr
.Lfunc_end1:
.size _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE, .Lfunc_end1-_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE
.fnend
.section .text._ZN4farm3bar17ha079dee3d7efd2c9E,"ax",%progbits
.p2align 2
.type _ZN4farm3bar17ha079dee3d7efd2c9E,%function
_ZN4farm3bar17ha079dee3d7efd2c9E:
.fnstart
.pad #20
sub sp, sp, #20
str r0, [sp, #8]
str r1, [sp, #4]
vmov.f32 s0, #1.000000e+00
vstr s0, [sp, #12]
vldr s0, [sp, #12]
vstr s0, [sp]
vmov.f32 s0, #1.000000e+00
vldr s2, [sp]
vcmpe.f32 s2, s0
vmrs APSR_nzcv, fpscr
bne .LBB2_4
movw r0, #0
str r0, [sp, #16]
b .LBB2_5
.LBB2_4:
movw r0, #1
str r0, [sp, #16]
.LBB2_5:
ldr r0, [sp, #16]
add sp, sp, #20
bx lr
.Lfunc_end2:
.size _ZN4farm3bar17ha079dee3d7efd2c9E, .Lfunc_end2-_ZN4farm3bar17ha079dee3d7efd2c9E
.fnend
.section .text.main,"ax",%progbits
.globl main
.p2align 2
.type main,%function
main:
.fnstart
.save {r11, lr}
push {r11, lr}
.setfp r11, sp
mov r11, sp
bl _ZN4farm3bar17ha079dee3d7efd2c9E
pop {r11, pc}
.Lfunc_end3:
.size main, .Lfunc_end3-main
.fnend
.section ".note.GNU-stack","",%progbits
.eabi_attribute 30, 5
#![feature(start, fundamental, lang_items, no_core, intrinsics)]
#![no_core]
#[lang="sized"]
#[fundamental]
pub trait Sized {}
#[lang="sync"]
pub unsafe trait Sync {}
#[lang="phantom_data"]
pub struct PhantomData<T:?Sized>;
#[lang="send"]
pub unsafe trait Send {}
#[lang="copy"]
pub trait Copy {}
#[lang="no_copy_bound"]
pub struct NoCopy;
#[lang = "eq"]
pub trait PartialEq<Rhs: ?Sized = Self> {
fn eq(&self, other: &Rhs) -> bool;
#[inline]
fn ne(&self, other: &Rhs) -> bool { !self.eq(other) }
}
impl PartialEq for f32 {
#[inline]
fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
#[inline]
fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
}
extern "rust-intrinsic" {
fn powif32(a: f32, x: i32) -> f32;
}
#[start]
fn bar(_: isize, _: *const *const u8) -> isize {
if unsafe { powif32(12345.0f32, 0) } == 1.0 {
0
} else {
1
}
}
; ModuleID = 'farm.cgu-0.rs'
source_filename = "farm.cgu-0.rs"
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7-unknown-linux-gnueabihf"
; Function Attrs: inlinehint uwtable
define internal zeroext i1 @"_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E"(float* noalias readonly dereferenceable(4), float* noalias readonly dereferenceable(4)) unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%2 = load float, float* %0
%3 = load float, float* %1
%4 = fcmp oeq float %2, %3
br label %bb1
bb1: ; preds = %start
ret i1 %4
}
; Function Attrs: inlinehint uwtable
define internal zeroext i1 @"_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE"(float* noalias readonly dereferenceable(4), float* noalias readonly dereferenceable(4)) unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%2 = load float, float* %0
%3 = load float, float* %1
%4 = fcmp une float %2, %3
br label %bb1
bb1: ; preds = %start
ret i1 %4
}
; Function Attrs: uwtable
define internal i32 @_ZN4farm3bar17ha079dee3d7efd2c9E(i32, i8**) unnamed_addr #1 {
entry-block:
%return = alloca i32
%tmp_ret = alloca float
br label %start
start: ; preds = %entry-block
%2 = call float @llvm.powi.f32(float 1.234500e+04, i32 0)
store float %2, float* %tmp_ret
%3 = load float, float* %tmp_ret
br label %bb1
bb1: ; preds = %start
%4 = fcmp oeq float %3, 1.000000e+00
br i1 %4, label %bb2, label %bb3
bb2: ; preds = %bb1
store i32 0, i32* %return
br label %bb4
bb3: ; preds = %bb1
store i32 1, i32* %return
br label %bb4
bb4: ; preds = %bb2, %bb3
%5 = load i32, i32* %return
ret i32 %5
}
; Function Attrs: nounwind readnone
declare float @llvm.powi.f32(float, i32) #2
define i32 @main(i32, i8**) unnamed_addr {
top:
%2 = call i32 @_ZN4farm3bar17ha079dee3d7efd2c9E(i32 %0, i8** %1)
ret i32 %2
}
attributes #0 = { inlinehint uwtable }
attributes #1 = { uwtable }
attributes #2 = { nounwind readnone }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}
.text
.syntax unified
.eabi_attribute 67, "2.09"
.eabi_attribute 6, 10
.eabi_attribute 7, 65
.eabi_attribute 8, 1
.eabi_attribute 9, 2
.fpu neon
.eabi_attribute 15, 1
.eabi_attribute 16, 1
.eabi_attribute 17, 2
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 34, 1
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 28, 1
.eabi_attribute 38, 1
.eabi_attribute 14, 0
.file "farm.cgu-0.rs"
.section ".text._ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E","ax",%progbits
.p2align 2
.type _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E,%function
_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E:
.fnstart
.pad #12
sub sp, sp, #12
str r0, [sp, #8]
str r1, [sp, #4]
b .LBB0_1
.LBB0_1:
ldr r0, [sp, #8]
vldr s0, [r0]
ldr r1, [sp, #4]
vldr s2, [r1]
vcmpe.f32 s0, s2
vmrs APSR_nzcv, fpscr
movw r2, #0
moveq r2, #1
str r2, [sp]
ldr r0, [sp]
and r0, r0, #1
add sp, sp, #12
bx lr
.Lfunc_end0:
.size _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E, .Lfunc_end0-_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2eq17he65631e424abb088E
.fnend
.section ".text._ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE","ax",%progbits
.p2align 2
.type _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE,%function
_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE:
.fnstart
.pad #12
sub sp, sp, #12
str r0, [sp, #8]
str r1, [sp, #4]
b .LBB1_1
.LBB1_1:
ldr r0, [sp, #8]
vldr s0, [r0]
ldr r1, [sp, #4]
vldr s2, [r1]
vcmpe.f32 s0, s2
vmrs APSR_nzcv, fpscr
movw r2, #0
movne r2, #1
str r2, [sp]
ldr r0, [sp]
and r0, r0, #1
add sp, sp, #12
bx lr
.Lfunc_end1:
.size _ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE, .Lfunc_end1-_ZN39_$LT$f32$u20$as$u20$farm..PartialEq$GT$2ne17h6c5fbdb136b46a0cE
.fnend
.section .text._ZN4farm3bar17ha079dee3d7efd2c9E,"ax",%progbits
.p2align 2
.type _ZN4farm3bar17ha079dee3d7efd2c9E,%function
_ZN4farm3bar17ha079dee3d7efd2c9E:
.fnstart
.pad #20
sub sp, sp, #20
str r0, [sp, #8]
str r1, [sp, #4]
vmov.f32 s0, #1.000000e+00
vstr s0, [sp, #12]
vldr s0, [sp, #12]
vstr s0, [sp]
vmov.f32 s0, #1.000000e+00
vldr s2, [sp]
vcmpe.f32 s2, s0
vmrs APSR_nzcv, fpscr
bne .LBB2_4
movw r0, #0
str r0, [sp, #16]
b .LBB2_5
.LBB2_4:
movw r0, #1
str r0, [sp, #16]
.LBB2_5:
ldr r0, [sp, #16]
add sp, sp, #20
bx lr
.Lfunc_end2:
.size _ZN4farm3bar17ha079dee3d7efd2c9E, .Lfunc_end2-_ZN4farm3bar17ha079dee3d7efd2c9E
.fnend
.section .text.main,"ax",%progbits
.globl main
.p2align 2
.type main,%function
main:
.fnstart
.save {r11, lr}
push {r11, lr}
.setfp r11, sp
mov r11, sp
bl _ZN4farm3bar17ha079dee3d7efd2c9E
pop {r11, pc}
.Lfunc_end3:
.size main, .Lfunc_end3-main
.fnend
.section ".note.GNU-stack","",%progbits
.eabi_attribute 30, 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment