- Common file formats for executables/ binaries
- Jargon
- Pre-requisite installations
- Exercises
- Challenges
- Quiz
Common file formats for executables/ binaries
Name | Operating System | Usage |
---|---|---|
Executable and Linkable Format (ELF) | Linux | Executables, Object code (.o), Shared Objects (.so), Kernel Objects (.ko), |
Portable Executable (PE) | Windows | Executables (.exe), Object code (.o), DLLs (.dll) |
Jargon
Other names: executable code, executable file, executable program, executable, binary
Pre-requisite installations
Mingw-w64
Mingw-w64 is an advancement of the original mingw.org project, created to support the GCC compiler on Windows systems. It also has a port for Linux to generate Windows executables.
1
2
sudo apt-get install mingw-w64-x86-64-dev
sudo apt-get install mingw-w64-i686-dev
Exercises
Files for exercise
add.c
1
2
3
4
5
6
int add(int a, int b)
{
int sum=0;
sum = a+b;
return sum;
}
main.c
1
2
3
4
5
6
7
int main(int argc, char const *argv[])
{
int res;
res = add(10,20);
printf("Result: %d\n", res);
return 0;
}
Exercise #1: Analyze an intermediate Object File Format
Compile add.c
using following command. This will generate the intermediate object file add.o
. Use the file
command to note the file type.
1
2
3
gcc -c -o add.o add.c
file add.o add.c
As it is observed the add.o
is stored in ELF format and add.c
is a ASCII format as it holds the source code.
Note: Since
add.o
is an intermediate object file we will be unable to execute it.
Exercise #2: Generate and analyze the executable format
1
2
3
4
5
6
7
8
# Generate the ELF executable format for Unices
gcc -o main main.c add.c
# Generate the PE executable format for Windows
i686-w64-mingw32-gcc -o main.exe main.c add.c
# Observe the executable formats
file main main.exe
Challenges
Challenge Files | File Format Details (Your answers in this column) |
---|---|
Challenge 1 | |
Challenge 2 | |
Challenge 3 | |
Challenge 4 |