Giter Site home page Giter Site logo

ferdi265 / dynamic-loader Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 4.0 44 KB

A simple Linux dynamic loader capable of loading simple binaries using simple shared libraries (no glibc support)

CMake 3.35% C 96.65%
c dynamic-linking systems-programming linux musl cmake dynamic-loading

dynamic-loader's Introduction

dynamic-loader

A simple dynamic library loader for Linux capable of loading simple binaries using simple shared libraries.

Features

  • Actually readable codebase for a dynamic loader
  • Loads simple shared objects (no glibc or musl support*)
  • Calls initializers and finalizers
  • Performs relocations at load-time (no lazy loading supported yet)
  • Supports dlopen(), dlsym(), and dlclose()
  • no support for threads or TLS, though rudimentary thread-safety is supported in the loader

* glibc and musl provide their own dynamic library loader that they expect to be loaded with:

  • ld-linux-x86_64.so.2 (aka ld.so) for glibc
  • ld-musl-x86_64.so.1 (a symlink to musl's libc.so) for musl

Dependencies

  • libmusl.a and musl-gcc (arch: musl, debian: musl musl-tools)
  • elf.h (arch: part of base, debian: libelf-dev)

Building

  • cmake -B build
  • cd build
  • make
  • run build/loader/libloader.so or any of the binaries in build/tests/bin/

Resources

This loader was written mostly by using specifications from refspecs.linuxbase.org, mainly the ELF spec and the x86_64 processor supplement.

For some parts of the early loader startup code (mainly the code in crt/), I also read the source code of musl libc to get a better understanding of typical ways to handle early loader init. To understand ELF symbol hash tables, I used multiple sources, but this blog post on flagpenguin.me was most useful.

dynamic-loader's People

Contributors

ferdi265 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.