Git Product home page Git Product logo

cs251-final's Introduction

Build RISC-V Compilation Environment

git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
./configure --prefix=/opt/riscv
make
export PATH=$PATH:/opt/riscv/bin

Compile Tools Usage Reference

Compile and run single C file

riscv64-unknown-elf-gcc -g <SOURCE.c> -o <PROGRAM>
./build/RISCV/gem5.opt configs/example/se.py -c <PATH/TO/SOURCE>

Disassembly

riscv64-unknown-elf-objdump -D <PROGRAM> > <DISASM.dasm>

It will contain codes of pk (proxy kernel). If you want to intermix source code with disassembly, use -S instead of -D.

Compile C files to assembly codes and link

riscv64-unknown-elf-gcc -S <SOURCE.c> -o <SOURCE.s>
riscv64-unknown-elf-gcc <SOURCE.s> -o <PROGRAM>

or

riscv64-unknown-elf-gcc -S <SOURCE.c> -o <SOURCE.s>
riscv64-unknown-elf-as <SOURCE.s> -o <SOURCE.o>
riscv64-unknown-elf-gcc <SOURCE.o> -o <PROGRAM>

The last line is actually equivalent to

riscv64-unknown-elf-ld /opt/riscv/riscv64-unknown-elf/lib/crt0.o /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/crtbegin.o <SOURCE.o> /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/crtend.o -L/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/ -lgcc --start-group -lc -lgloss --end-group -o <PROGRAM>

We can define our own link script link.ld and get rid of newlib.

Compile assembly codes without newlib

See Makefile and examples/assembly

Compile assembly and C codes

See Makefile and examples/withc

cs251-final's People

Contributors

zjkmxy avatar jonnykong avatar

Stargazers

 avatar Yukang Zhu avatar Houxiang Ji avatar XiaolingYi avatar Mulong Luo avatar  avatar

Watchers

James Cloos avatar  avatar sdyz0515 avatar Weijia Yuan avatar  avatar  avatar

Forkers

lmlaaron isqxie

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.