Giter Site home page Giter Site logo

robbedgreef / safecc Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 213 KB

C Compiler that strives to be as (memory) safe as possible.

License: GNU General Public License v3.0

CMake 0.29% Shell 0.11% C++ 91.84% C 7.77%
c compiler c-compiler memory-safety linux x86

safecc's Introduction

SafeCC

SafeCC is a simple POC C compiler that tries to help the user find as many bugs at compile time as possible. This includes out-of-scope checks, memory leakage tracking, double free checking and more. The compiler is very much in its early stages and thus is currently unsuitable for any 'real' development.

Getting started

SafeCC should normally be pretty easy to build with any ordinary c++ compiler, so just grab a copy with

git clone https://github.com/RobbeDGreef/SafeCC.git

and follow the installation guide below.

Prerequisites

Since this compiler currently doesn't have its own preprocessor, it will try to invoke gcc for the preprocessing step. This means that gcc should be in your PATH. The same goes ld for the linking process and nasm for the assembling step.

SafeCC is build with cmake and make so you need will need those too.

You can install all these by running (on a debian-based system)

sudo apt-get install build-essentials nasm cmake

Installing

The installation steps are very simple. We have made it easy for you (and me), if you just want to build the project quickly run ./build.sh in the main directory. If you want some more control read below.

SafeCC is build with cmake and it is good practice to build to project in a seperate 'build' directory, so that is what we do here:

mkdir build
cd build
cmake ..
make all
mv safecc ../safecc
cd ..

as you can see this means we have to move the executable out of the build folder but we can easily do that with the mv command.

You can now compile C source files with

./safecc -o <outfile> <infiles>

Running the tests

The tests folder includes a fair amount of test files, to test them all at once run ./tests/tests.sh. If you want to try one test case individually run ./tests/test.sh tests/files/<testName.c>, where <testName.c> is obviously changed to the test name you want to try.

Features

Currently working on checks for:

  • Out-of-scope references
  • Use after free bugs
  • Wild pointer (use before initialization)
  • Double free bugs
  • Memory leaks

This is supposed to expand in the future and the current tests are still in early development so it might not behave as expected

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process of submitting pull requests to us.

License

This project is licensed under GPL3 License - see the LICENSE.md file for details

Acknowledgements

These other C compilers were definitely a great guide on how to tackle this problem

  • The subC compiler
  • SmallerC compiler

Resources that deserve a special thank you

safecc's People

Contributors

robbedgreef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ranjian0

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.