-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lifting this bitcode results in an empty function #146
Comments
pgoodman
added
bug
Something isn't working
decomp
Related to LLVM IR to C decompiler
labels
Jun 23, 2021
|
Another example, with simpler bitcode: ; ModuleID = '/tmp/challenge-3/program_c/src/gpio.ll'
source_filename = "gpio.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu-elf"
%struct.pin_type = type { i32, i32, i32, i32, i32 }
%sub_4021c0__Ai_Sbv_B_78.frame_type_part0 = type <{ [64 x i8] }>
@pinOL = dso_local local_unnamed_addr global %struct.pin_type zeroinitializer, align 4
@pinIL = dso_local local_unnamed_addr global %struct.pin_type zeroinitializer, align 4
@pinIR = dso_local local_unnamed_addr global %struct.pin_type zeroinitializer, align 4
@pinOR = dso_local local_unnamed_addr global %struct.pin_type zeroinitializer, align 4
@__anvill_reg_RBP = external local_unnamed_addr global i64
@__anvill_sp = external global i8
@__anvill_ra = external global i8
@__anvill_pc = external global i8
@llvm.compiler.used = appending global [15 x i8*] [i8* bitcast (i64 (i32, i8*, i64)* @write to i8*), i8* bitcast (i64 (i32, i64, i32)* @lseek to i8*), i8* bitcast (i64 (i32, i8*, i64)* @read to i8*), i8* bitcast (i32 (i8*, i32, ...)* @open to i8*), i8* bitcast (void ()* @initialize_pins to i8*), i8* bitcast (%struct.pin_type* (%struct.pin_type*, i32)* @get_pin to i8*), i8* bitcast (void (i32, i32)* @set_power to i8*), i8* bitcast (void (i32)* @set_state to i8*), i8* bitcast (void (i32)* @enable_pin to i8*), i8* bitcast (void (i32)* @disable_pin to i8*), i8* bitcast (void (i32)* @polarity_normal to i8*), i8* bitcast (void (i32, i8*, i8)* @set_period to i8*), i8* bitcast (void (i32, i8*)* @get_period to i8*), i8* bitcast (void (i32, i32)* @set_duty to i8*), i8* bitcast (void (i32, i8*)* @get_duty to i8*)], section "llvm.metadata"
; Function Attrs: noinline
declare x86_64_sysvcc void @initialize_pins() #0
; Function Attrs: noinline
declare x86_64_sysvcc i32 @open(i8*, i32, ...) #0
; Function Attrs: noinline
declare x86_64_sysvcc %struct.pin_type* @get_pin(%struct.pin_type*, i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @set_power(i32, i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc i64 @lseek(i32, i64, i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc i64 @write(i32, i8*, i64) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @set_state(i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @enable_pin(i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @disable_pin(i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @polarity_normal(i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @set_period(i32, i8*, i8) #0
; Function Attrs: noinline
define x86_64_sysvcc void @get_period(i32 %0, i8* %1) #0 {
%3 = alloca %sub_4021c0__Ai_Sbv_B_78.frame_type_part0, align 8
%4 = load i64, i64* @__anvill_reg_RBP, align 8
%5 = ptrtoint i8* %1 to i64
%6 = getelementptr inbounds %sub_4021c0__Ai_Sbv_B_78.frame_type_part0, %sub_4021c0__Ai_Sbv_B_78.frame_type_part0* %3, i64 0, i32 0, i64 56
%7 = bitcast i8* %6 to i64*
store i64 %4, i64* %7, align 8
%8 = getelementptr inbounds %sub_4021c0__Ai_Sbv_B_78.frame_type_part0, %sub_4021c0__Ai_Sbv_B_78.frame_type_part0* %3, i64 0, i32 0, i64 52
%9 = bitcast i8* %8 to i32*
store i32 %0, i32* %9, align 4
%10 = getelementptr inbounds %sub_4021c0__Ai_Sbv_B_78.frame_type_part0, %sub_4021c0__Ai_Sbv_B_78.frame_type_part0* %3, i64 0, i32 0, i64 40
%11 = bitcast i8* %10 to i64*
store i64 %5, i64* %11, align 8
%12 = bitcast %sub_4021c0__Ai_Sbv_B_78.frame_type_part0* %3 to i64*
store i64 4202971, i64* %12, align 8
%13 = getelementptr inbounds %sub_4021c0__Ai_Sbv_B_78.frame_type_part0, %sub_4021c0__Ai_Sbv_B_78.frame_type_part0* %3, i64 0, i32 0, i64 16
%14 = bitcast i8* %13 to %struct.pin_type*
%15 = call %struct.pin_type* @get_pin(%struct.pin_type* nonnull %14, i32 %0)
%16 = getelementptr inbounds %sub_4021c0__Ai_Sbv_B_78.frame_type_part0, %sub_4021c0__Ai_Sbv_B_78.frame_type_part0* %3, i64 0, i32 0, i64 20
%17 = bitcast i8* %16 to i32*
%18 = load i32, i32* %17, align 4
store i64 4202985, i64* %12, align 8
%19 = call i64 @lseek(i32 %18, i64 0, i32 0)
%20 = load i32, i32* %17, align 4
%21 = bitcast i8* %10 to i8**
%22 = load i8*, i8** %21, align 8
store i64 4203002, i64* %12, align 8
%23 = call i64 @read(i32 %20, i8* %22, i64 100)
ret void
}
; Function Attrs: noinline
declare x86_64_sysvcc i64 @read(i32, i8*, i64) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @set_duty(i32, i32) #0
; Function Attrs: noinline
declare x86_64_sysvcc void @get_duty(i32, i8*) #0
attributes #0 = { noinline }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 12.0.0 (https://github.com/trailofbits/vcpkg.git 4592a93cc4ca82f1963dba08413c43639662d7ae)"} |
I think the issue is this:
I don't know why its a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
enable_pin
function is non-empty in the bitcode, but empty in the decompiled source.Decompiled source:
The text was updated successfully, but these errors were encountered: