zoukankan      html  css  js  c++  java
  • RISCV from scratch 4: Creating a function prologue for our UART driver (2 / 3)

    
    

    Setup

    If you have worked through all the previous posts in this series, you can cd to your riscv-from-scratch directory and skip this section. If you’re new to this series and would like to follow along, keep reading!

    1. Follow these instructions from the first post to install the GNU RISC-V toolchain and a version of QEMU with RISC-V emulation capabilities.
    2. Clone or fork the riscv-from-scratch repo:
    git clone git@github.com:twilco/riscv-from-scratch.git
    # or `git clone https://github.com/twilco/riscv-from-scratch.git` to clone
    # via HTTPS rather than SSH
    # alternatively, if you are a GitHub user, you can fork this repo.
    # https://help.github.com/en/articles/fork-a-repo
    cd riscv-from-scratch
    1. Check out the pre-function-prologue-impl branch which contains the code prerequisites for this post in the src directory:
    git checkout pre-function-prologue-impl
    1. Copy the customized linker script riscv64-virt.ld, minimal C runtime crt0.s, NS16550A UART driver skeleton ns16550a.s, and main.c to our working directory:
    # note: this will overwrite any existing files you may have in `work`
    cp -a src/. work


    riscv64-unknown-elf-gcc -g -ffreestanding -O0 -Wl,--gc-sections \
        -nostartfiles -nostdlib -nodefaultlibs -Wl,-T,riscv64-virt.ld \
        crt0.s main.c ns16550a.c
     

    -ffreestanding 告诉编译器标准库可能不存在,因此不能做任何假设。在主机环境中运行应用程序时,此选项不是必需的,但是我们没有这样做,因为重要的是告诉编译器该信息。

    -Wl 是逗号分隔的标志列表,以传递给链接器 ld。 --gc-sections 代表“垃圾收集 section”,告诉ld 在链接后删除未使用的节。 -nostartfiles,-nostdlib 和 -nodefaultlibs 分别告诉链接器不要链接任何标准系统启动文件(例如默认 crt0),任何标准系统 stdlib 实现或任何标准系统默认可链接库。我们提供了自己的 crt0 和链接描述文件,因此传递这些标志以告知编译器,我们不希望使用这些默认设置中的任何一个。

    -T 允许你将你的链接器脚本路径传给链接器,在我们这次实验中就是 riscv64-virt.ld 。最后,加上我们想要编译的文件名就可以了。
     





    https://twilco.github.io/riscv-from-scratch/2019/07/28/riscv-from-scratch-4.html
  • 相关阅读:
    优秀JS学习站点
    一些比较好的论坛、博客
    最全前端问题及答案总结[转]
    EDM制作要点
    前端技术-调试工具(下)
    前端技术-调试工具(上)
    smartJQueryZoom(smartZoom) 的使用方法
    修改博客园日历的默认样式
    smartJQueryZoom(smartZoom) 存在的兼容性BUG,以及解决方法
    javascript实战 : 简单的颜色渐变
  • 原文地址:https://www.cnblogs.com/dream397/p/15674735.html
Copyright © 2011-2022 走看看