Closed sanghwa95 closed 6 months ago
Thanks for the report. Can you share your .so file somewhere?
https://github.com/sanghwa95/tmp/blob/main/libapp.so Above is so file link. Thank you for quick response.
I see two problems:
You are giving the address 0 to ParseInstr
, which is an invalid address. You may want to lift only the .text section. For instance:
let isa = ISA.OfString "aarch64"
let hdl = BinHandle.Init (isa, "libapp.so")
let sec = hdl.BinFile.GetSections (name=".text") |> Seq.exactlyOne
let ins = BinHandle.ParseInstr (hdl, sec.Address)
Even with the above code, you will see an error because the text section starts with an invalid instruction. You should be able to confirm this using objdump
or similar tools. A valid address starts @ 0x120068
. So the following code will work, for instance.
let isa = ISA.OfString "aarch64"
let hdl = BinHandle.Init (isa, "libapp.so")
let sec = hdl.BinFile.GetSections (name=".text") |> Seq.exactlyOne
let ins = BinHandle.ParseInstr (hdl, sec.Address + 0x68UL)
ins.Translate hdl.TranslationContext
|> Pp.stmtsToString
|> printfn "%s"
So this is not really a bug. You should gracefully handle parsing exceptions for invalid instructions in order to properly lift binaries.
Thanks for your kind reply!
Describe the bug I want to lift a .so file which is from Android APK file. But an error occurs. Other common .so files also occur the same issue. How can I lift .so file?
To Reproduce Steps to reproduce the behavior:
open B2R2 open B2R2.FrontEnd
[]
let main argv =
let isa = ISA.OfString "armv8a64"
let handler = BinHandler.Init (isa, "libapp.so")
let ins = BinHandler.ParseInstr handler 0UL
ins.Translate handler.TranslationContext |> printfn "%A"
0
Screenshots
Environment (please complete the following information):