Analyzing executable files
It is very difficult to analyze the assembly code generated by the swiftc compiler. To make our lives easier, we will use a Hopper Disassembler tool to disassemble executable files, generating a piece of pseudocode and analyzing it. You can download the free version of Hopper from http://www.hopperapp.com.
The Hopper Disassembler tool can work with binary, executable, and object files. The easiest way of using it is by generating an executable file with the swiftc main.swift
command and opening it in Hopper. You can simply drag and drop the main
executable file to open it in Hopper.
On the left-hand side, you can find all the labels for functions and variables and navigate to them. The search feature is very useful when you are analyzing a big project with many functions. In the center is an assembly code; you can press Alt + Enter to see the pseudocode for the current procedure. It is much easier to analyze high-level pseudocode.
We can also compile an application...