Skip to content

Piero Bosio Social Web Site Personale Logo Fediverso

Social Forum federato con il resto del mondo. Non contano le istanze, contano le persone

Hello World in C Without Linking in Libraries

Uncategorized
1 1 0
  • Hello World in C Without Linking in Libraries

    If there’s one constant with software developers, it is that sometimes they get bored. At these times, they tend to think dangerous thoughts, usually starting with ‘What if…’. Next you know, they have gone down a dark and winding rabbit hole and found themselves staring at something so amazing that the only natural conclusion that comes to mind is that while educational, it serves no immediate purpose.

    The idea of applying this to snipping out the <stdio.h> header in C and the printf() function that it provides definitely is a good example here. Starting from the typical Hello World example in C, [Old Man Yells at Code] over at YouTube first takes us from the standard dynamically linked binary at a bloated 16 kB, to the statically linked version at an eyepopping 767 kB.

    To remove any such dynamic linkages, and to keep file sizes somewhat sane, he then proceeds to first use the write()function from the <unistd.h> header, which does indeed cut out the <stdio.h> include, before doing the reasonable thing and removing all includes by rewriting the code in x86 assembly.

    While this gets the final binary size down to 9 kB and needs no libraries to link with, it still performs a syscall, after setting appropriate register values, to hand control back to the kernel for doing the actual printing. If you try doing something similar with syscall(), you have to link in libc, so it might very well be that this is the real way to do Hello World without includes or linking in libraries. Plus the asm keyword part of C, although one could argue that at this point you could just as well write everything in x86 ASM.

    Of course, one cannot argue that this experience isn’t incredibly educational, and decidedly answers the original ‘What if…’ question.

    youtube.com/embed/gVaXLlGqQ-c?…


    hackaday.com/2025/10/29/hello-…


Gli ultimi otto messaggi ricevuti dalla Federazione
Post suggeriti
  • 0 Votes
    1 Posts
    0 Views
    Il vaccino mRNA aiuta a sconfiggere il cancro. Un altro brutto colpo per la disinformazione novax - Valigia Bluhttps://www.valigiablu.it/vaccini-mrna-tumori-terapia-genica/> Uno studio su pazienti con tumore al polmone avanzato e melanoma metastatico ha mostrato che chi aveva ricevuto il vaccino a mRNA per Covid-19 insieme agli inibitori del checkpoint immunitario (ICI) aveva una sopravvivenza più lunga. Lo studio apre nuove prospettive per l’uso dei vaccini a mRNA oltre la prevenzione delle infezioni.
  • 0 Votes
    1 Posts
    0 Views
    Frankenstein Review: Guillermo Del Toro's Gloriously Gothic Monster Movie Is Alive - SlashFilmhttps://www.slashfilm.com/1998790/frankenstein-guillermo-del-toro-movie-review/> Guillermo del Toro's Frankenstein is a beautiful blend of horror and gothic romance, with a stunning performance from Jacob Elordi. Here's our review.
  • 0 Votes
    1 Posts
    0 Views
    Aggressioni neofasciste: l'ottobre nero smonta la retorica di Melonihttps://www.lanotiziagiornale.it/sette-aggressioni-neofasciste-in-un-mese-lottobre-nero-smentisce-la-retorica-di-giorgia-meloni-sulla-violenza-della-sinistra/> Mentre la premier accusa la sinistra di diffondere odio, ottobre segna un’escalation di violenze di matrice neofascista in tutta Italia
  • Accise e facce toste | LA NOTIZIA

    Uncategorized
    1
    0 Votes
    1 Posts
    0 Views
    Accise e facce toste | LA NOTIZIAhttps://www.lanotiziagiornale.it/accise-e-facce-toste/> Il governo dice che pareggia le accise sui carburanti, perché diminuisce quelle sulla benzina e aumenta quelle sul diesel. Ma quale pareggio e pareggio! Si ... Read more