Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:01:57+00:00 2026-05-11T04:01:57+00:00

I wonder if I could write a program in the C -programming language that

  • 0

I wonder if I could write a program in the C-programming language that is executable, albeit not using a single library call, e.g. not even exit()?

If so, it obviously wouldn’t depend on libraries (libc, ld-linux) at all.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:01:57+00:00Added an answer on May 11, 2026 at 4:01 am

    I suspect you could write such a thing, but it would need to have an endless loop at the end, because you can’t ask the operation system to exit your process. And you couldn’t do anything useful.

    Well start with compiling an ELF program, look into the ELF spec and craft together the header, the program segments and the other parts you need for a program. The kernel would load your code and jump to some initial address. You could place an endless loop there. But without knowing some assembler, that’s hopeless from the start on anyway.

    The start.S file as used by glibc may be useful as a start point. Try to change it so that you can assemble a stand-alone executable out of it. That start.S file is the entry point of all ELF applications, and is the one that calls __libc_start_main which in turn calls main. You just change it so it fits your needs.

    Ok, that was theoretical. But now, what practical use does that have?

    Answer to the Updated Question

    Well. There is a library called libgloss that provides a minimal interface for programs that are meant to run on embedded systems. The newlib C library uses that one as its system-call interface. The general idea is that libgloss is the layer between the C library and the operation system. As such, it also contains the startup files that the operation system jumps into. Both these libraries are part of the GNU binutils project. I’ve used them to do the interface for another OS and another processor, but there does not seem to be a libgloss port for Linux, so if you call system calls, you will have to do it on your own, as others already stated.

    It is absolutely possible to write programs in the C programming language. The linux kernel is a good example of such a program. But also user programs are possible. But what is minimally required is a runtime library (if you want to do any serious stuff). Such one would contain really basic functions, like memcpy, basic macros and so on. The C Standard has a special conformance mode called freestanding, which requires only a very limited set of functionality, suitable also for kernels. Actually, i have no clue about x86 assembler, but i’ve tried my luck for a very simple C program:

    /* gcc -nostdlib start.c */ int main(int, char**, char**);  void _start(int args) {     /* we do not care about arguments for main. start.S in       * glibc documents how the kernel passes them though.      */     int c = main(0,0,0);      /* do the system-call for exit. */     asm('movl   %0,%%ebx\n' /* first argument */         'movl   $1,%%eax\n' /* syscall 1 */         'int    $0x80'      /* fire interrupt */         : : 'r'(c) :'%eax', '%ebx'); }  int main(int argc, char** argv, char** env) {     /* yeah here we can do some stuff */     return 42; } 

    We’re happy, it actually compiles and runs 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 96k
  • Answers 96k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Could you not just require that a SpriteFont be passed… May 11, 2026 at 7:11 pm
  • Editorial Team
    Editorial Team added an answer This has been confirmed to me by someone from Apple… May 11, 2026 at 7:11 pm
  • Editorial Team
    Editorial Team added an answer I'm not really clear on what you are doing. It… May 11, 2026 at 7:11 pm

Related Questions

I've been wondering about how hard it would be to write some Python code
I find that I am cutting and pasting a LOT when I program. For
I wonder if I could read or write shared int value without locking on
In any DBMS that's more than half-baked, there is a distinction between a read

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.