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
  • 相关阅读:
    cocos2d-x3.6 连连看连通画线
    POJ输出状态的逻辑。
    BeanUtils数据封装与表单JavaBean
    二分法查找 --JS 实现
    Unix/Linux环境C编程新手教程(5) Red Hat Enterprise Linux(RHEL)环境搭建
    我们都傻不啦叽为《围住神经猫》免费推广!
    updating error reports database解决方案
    nutwk的maven中央仓库及配置
    Maven error in eclipse (pom.xml) : Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4
    SFTP环境搭建及客户代码调用公共方法封装
  • 原文地址:https://www.cnblogs.com/dream397/p/15674735.html
Copyright © 2011-2022 走看看