lifting-bits / anvill

anvill forges beautiful LLVM bitcode out of raw machine code
GNU Affero General Public License v3.0
342 stars 39 forks source link

Return Address not eliminated for x86-64 #313

Closed Ninja3047 closed 2 years ago

Ninja3047 commented 2 years ago
define i32 @main(i32 %0, ptr %1, ptr %2) #0 !pc !11 {
  %4 = call ptr @llvm.addressofreturnaddress.p0(), !pc !12
  %5 = load i64, ptr @__anvill_stack_0, align 8, !pc !12
  %6 = call i64 @fizz_buzz(i32 100) #3, !pc !13
  store i64 %5, ptr %4, align 8, !pc !12
  ret i32 0, !pc !12
}

for some reason anvill emits a @llvm.addressofreturnaddress.p0 and I expect these to be eliminated and look closer to

define i32 @main(i32 %0, ptr %1, ptr %2) #0 !pc !11 {
  %6 = call i64 @fizz_buzz(i32 100) #3, !pc !13
  ret i32 0
}

I use the following specification test-fizzbuzz-elf-x64.spec.json.txt

and the following anvill command to lift it (main is at 0x1210)

anvill-decompile-json --add-names --spec test-fizzbuzz-elf-x64.spec.json -lift_list 1210 -ir_out test-fizzbuzz-elf-x64-main.ll

the anvill version is

Commit Hash: d0063e0054472be42ca71bcfa087f2f5746c0bbf
Commit Date: 2022-07-29 08:03:46 -0400
Ninja3047 commented 2 years ago

Appears to be fixed on the latest version