Coder Social home page Coder Social logo

aqcc's Introduction

AnQou C Compiler: aqcc

aqcc is yet another tiny self-hosted C compiler with an also tiny assembler, linker and standard C library.

To Build

Just make.

Usage

./aqcc [options] file...

options are:

  • -S: output an assembly file.
  • -c: output an object file.
  • -o: set the output file name.

To find the detail, try make selfself_test, which tells you all the things.

Note

  • aqcc is a product of Security Camp 2018. Special thanks to @rui314 san and @hikalium san.
  • Many features, functions and so on have not yet been implemented in aqcc that a C compiler generally has. Feel free to implement missing features and to send pull requests :)

AnQou C Compiler の使い方

aqcc をビルド

make としてください。生成物を削除したいときは、 make clean などとしてください。

aqcc の挙動をテスト

  • make test
    • 第一世代(gccなどによりコンパイルされたaqcc)をテスト
  • make self_test
    • 第二世代(第一世代によりコンパイルされたaqcc)をテスト
  • make selfself_test
    • 第三世代(第二世代によりコンパイルされたaqcc)をテスト
    • 第二世代と第三世代に違いがないことも確認されます。

一般のCファイルをコンパイル

./aqcc [options] file...

options には以下のようなものを使用できます。

  • -S アセンブリファイルを出力します。
  • -c オブジェクトファイルを出力します。
  • -o out 出力ファイル名を指定できます。

program.c を以下のようにしてコンパイルし、実行できます。 aqccprogram.c などは適宜読みかえてください。

$ ./aqcc program.c -o program
$ ./program

なお、#include <stdio.h> などとはできません。 program.c の中にこのような構文が含まれている場合は、取り除いて下さい。 その代わりに、自前で puts() 関数などの プロトタイプ宣言を program.c の冒頭に加えてください。 なお、カレントディレクトリ内のファイルはインクルードできますので、 #include "aqcc.h" などとインクルードして、 aqcc.h に記されているプロトタイプ宣言を流用できます。

また、標準ライブラリのうち提供されている機能はごく僅かです。 stdlib.c などを参照して下さい。aqccが自動でこれらをリンクすることはありません。明示的に指定してください。

謝辞

aqccはセキュリティキャンプ全国大会2018の成果物です。 講師の@rui314さんと@hikaliumさんに深く感謝申し上げます。

資料

aqcc's People

Contributors

hiromi-mi avatar hsjoihs avatar ushitora-anqou avatar vain0x avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aqcc's Issues

Undefined reference error occurred when compiling ld dir

gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)

  1. cd aqcc/ld dir
  2. make

The following error occurred:

/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400144
/tmp/ccs55tqL.o: In function exit': /home/xxxx/compiler/aqcc/ld/stdlib.c:113: undefined reference to syscall'
/tmp/ccs55tqL.o: In function brk': /home/xxxx/compiler/aqcc/ld/stdlib.c:120: undefined reference to syscall'
/tmp/ccs55tqL.o: In function open': /home/xxxx/compiler/aqcc/ld/stdlib.c:150: undefined reference to syscall'
/tmp/ccs55tqL.o: In function close': /home/xxxx/compiler/aqcc/ld/stdlib.c:153: undefined reference to syscall'
/tmp/ccs55tqL.o: In function write': /home/xxxx/compiler/aqcc/ld/stdlib.c:161: undefined reference to syscall'
/tmp/ccs55tqL.o:/home/xxxx/compiler/aqcc/ld/stdlib.c:166: more undefined references to `syscall' follow
collect2: error: ld returned 1 exit status
Makefile:8: recipe for target 'ld' failed

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.