msuiche / porosity

*UNMAINTAINED* Decompiler and Security Analysis tool for Blockchain-based Ethereum Smart-Contracts

Home Page:https://www.comae.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes for compiling on macOS

beaugunderson opened this issue · comments

I had to add this to Makefile to get it to work:

CXX=g++  # or c++, clang works too
CXXFLAGS=-std=c++14

I also had to inline assertThrow from Assert.h into Instruction.h because the compiler complained that it wasn't defined--my C++ knowledge is limited so I don't have a guess as to why.

That would make a good pool request :)

Yes, pull request please :)

OK, PR #6 for the Makefile change but I don't know how to fix the issue with assertThrow other than moving the definition to Instruction.h, which seems wrong. :)

For what it's worth here's the compiler error:

In file included from Contract.cpp:18:
In file included from ./Porosity.h:41:
In file included from ./PorosityDefs.h:20:
./Instruction.h:214:56: error: use of undeclared identifier 'InvalidOpcode'
            assertThrow(1 <= _number && _number <= 32, InvalidOpcode, "Invalid PUSH instruction requested.");

I changed InvalidOpcode to a string when I was initially investigating; that results in this error:

In file included from Contract.cpp:18:
In file included from ./Porosity.h:41:
In file included from ./PorosityDefs.h:20:
./Instruction.h:214:13: error: use of undeclared identifier 'assertThrow'
            assertThrow(1 <= _number && _number <= 32, "InvalidOpcode", "Invalid PUSH instruction requested.");

Also it will be great to make it available for linux

Update: i've changed the flag suggested by @beaugunderson but now i got this error

g++ -std=c++14 -c -o Utils.o Utils.cpp In file included from Porosity.h:32:0, from Utils.cpp:17: Common.h:48:66: fatal error: boost_multiprecision_number_compare_bug_workaround.hpp: No such file or directory

Update #2: i've downloaded this file but still cannot compile because of various erros like this one

Statement.h: In member function ‘std::__cxx11::string Statement::getStatementStr()’: Statement.h:135:84: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

Any ideas?

I'm getting segfaults when I run the OS X compiled binary - is anyone else?

$ export abi=`cat ~/code/java/web3j/src/test/resources/solidity/greeter/build/greeter.abi`
$ export code=`cat ~/code/java/web3j/src/test/resources/solidity/greeter/build/greeter.bin`
$ ./porosity --abi $abi --code $code --decompile --verbose 0
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <support@comae.io>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.

Segmentation fault: 11
$ ./porosity --abi $abi --code $code --list --verbose 0
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <support@comae.io>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.

Segmentation fault: 11

abi and bin code is as per https://github.com/web3j/web3j/tree/master/src/test/resources/solidity/greeter/build

See deployed code here https://ropsten.etherscan.io/tx/0x654a48e6c24548a1f6c8556747ac849ca8344499b16605b8bd3f55aa9939749d

@conor10 can you put the ABI and code in your comment (or a gist) as a bash script so I can easily run it?

@conor10 sorry, I wanted something to copy and paste :) willing to help but limited time

@beaugunderson can you confirm the macOS compilation issue had been fixed with the recent pull request ?

@beaugunderson can you confirm the macOS compilation issue had been fixed with the recent pull request ?

I added PR #16 to finish the fix for OSX

I'll add a new PR with doc cleanup and OSX build instructions