Giter Site home page Giter Site logo

rt0's Introduction

rt0

A minimal C runtime for Linux i386 & x86_64

Features

  • Implemented in just 87 SLOC of C code.
  • Just 2 lines of GCC inline ASM for i386, or,
  • Just 6 lines GCC inline ASM for x86_64
  • Small runtime providing just argc, argv, envp, __environ, _exit, and syscall0/1/2/3/4/5/6
  • Small binary sizes vs. other libc's
Binary Arch Size Purpose Compile Args
librt0.a i386 4390 Startup code+syscall -Os -nostdlib -fomit-frame-pointer
librt0.a x86_64 6086 Startup code+syscall -Os -nostdlib -fomit-frame-pointer
t/hello.exe i386 1272 Hello World\n -Os -s -nostdlib -fomit-frame-pointer
t/hello.exe x86_64 1520 Hello World\n -Os -s -nostdlib -fomit-frame-pointer
hello.exe i386 5532 Hello World\n with glibc -Os -s -fomit-frame-pointer
hello.exe x86_64 6240 Hello World\n with glibc -Os -s -fomit-frame-pointer

Compiler: GCC 4.8.2, OS: Ubuntu 14.04.1, Source: Author

See the musl libc comparison to see how other libc's fare.

Building

Try:

  • make
  • make librt0.a
  • make test
  • make runtest
  • In bash, DEST=/ PREFIX=usr/local make install, or simply, make install

Usage

  • Include rt0/rt0.h for __environ, _exit
  • Include rt0/syscall.h for SYS_*, syscall0/1/2/3/4/5/6
  • Define main as int main( int, char**, char** )
  • Compile your code with -nostdlib, e.g., cc -c prog.c -nostdlib -o prog.o
  • Link with librt0, e.g., cc prog.o -nostdlib -lrt0 -o prog

References

Other small libc's and runtimes

rt0's People

Contributors

lpsantil avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.