Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a \"Hello, World! C program that produces the smallest executable binary w

ID: 3870886 • Letter: W

Question

Write a "Hello, World! C program that produces the smallest executable binary which prints out “Hello, world!” to the standard output without an error. we’re trying to minimize size of the executable of a very simple program

– so you need to focus on shedding weight in other areas.

The rules: - The resulting binary must be ELF-compliant 64-bit x86 executable. It should end its execution correctly, meaning that it must exit with error code 0 (zero). These conditions can be tested using ‘readelf’ and ‘file’ commands and checking the error code in shell by “echo $?” after execution.

- You should use C file as the source.

without any size reduction, you should get a binary with around 8KB in size. With some efforts, you can obtain a binary less than 1KB

use system calls instead of printf(), try and eliminate main by using _start and _exit, remove boiler plate sections of ELF executable

Explanation / Answer

#include<unistd.h>
#include<sys/syscall.h>

void _start()
{
const char msg[] = "Hello World...!!! ";
syscall(SYS_write, 0, msg, sizeof(msg)-1);
syscall(SYS_exit, 0);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote