Ssa to go decompiler

Is there a way to reverse an output from ssa interpreter back to go?

What is SSA? And what does an interpreter for it do? Please ask a question that we can understand.

SSA is one of the intermediate stages of a compiler, including the Go compiler. I haven’t heard about something that goes in the other direction to produce Go from an SSA representation, though. My guess, without exhaustingly investigating it, is that it does not exist.

What do you want it for, @Ariel_T?

I am seeing an output of a go code at the ssa stage, using something like https://golang-ssaview.herokuapp.com/ , I would like to convert to either a readable code or a workable executable. Can this be performed? Can the SSA be compiled further to produce an executable form? Is there some other approach that will allow me to understand and make the SSA either readable or executable.

This is part of what I see:

Starting main.init.
.0:
t0 = *init$guard
if t0 goto 2 else 1
.1:
*init$guard = true:bool
t1 = strconv.init()
Starting strconv.init.
.0:
t0 = *init$guard
if t0 goto 2 else 1
.1:
*init$guard = true:bool
t1 = math.init()
Starting math.init.
.0:
t0 = *init$guard
if t0 goto 2 else 1
.1:
*init$guard = true:bool
t1 = hasSSE4()
Starting math.hasSSE4 at /usr/lib/go-1.7/src/math/floor_asm.go:10:6.
(external)
Returning from math.hasSSE4, proceeding math.init at /usr/lib/go-1.7/src/math/floor_asm.go:12:22.
*useSSE4 = t1
t2 = &_gamP[0:int]
t3 = &_gamP[1:int]
t4 = &_gamP[2:int]
t5 = &_gamP[3:int]
t6 = &_gamP[4:int]
t7 = &_gamP[5:int]
t8 = &_gamP[6:int]
*t2 = 0.00016012:float64
*t3 = 0.00119135:float64
*t4 = 0.0104214:float64
*t5 = 0.0476368:float64
*t6 = 0.207448:float64
*t7 = 0.494215:float64
*t8 = 1:float64

see interp package - golang.org/x/tools/go/ssa/interp - Go Packages

Hey, I’m also in need of the same stuff.
I’ve tried looking at the interp package but honestly have no idea how to use it against a text file. I’d really appreciate a small code sample to illustrate how to do this. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.