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
  • 相关阅读:
    Eclispe造成的tomcat占用端口 无法启动 强制终止进程 转载
    JavaScript在页面中的执行顺序(理解声明式函数与赋值式函数) 转载
    spket IDE插件更新地址
    SQL 语句外键 a foreign key constraint fails
    面试技能树 转载
    简单粗暴 每个servlet之前都插入一段代码解决 乱码问题
    记录一个因sqlmap导致的错误
    Java与数据库数据类型对应表
    乐观锁与悲观锁
    maven打的包中含源文件jar包
  • 原文地址:https://www.cnblogs.com/dream397/p/15674735.html
Copyright © 2011-2022 走看看