[otbn] Properly generate multi-section output in otbn-rig

The code was trying to use the .offset assembler directive to tell it
where to put things, but this turns out not to work at all. So we now
generate a linker script as well as the assembly code.

The command line is pretty horrible, but will be tidied up
soon (splitting up "generate me some snippets" and "turn them into
assembly"). For now, you can run it as

    ./hw/ip/otbn/util/otbn-rig \
      --asm-output gen.S \
      --ld-output gen.ld \
      -o gen.json

The resulting gen.S looks something like this:

    /* Section 0 (addresses [0x0000..0x0007]) */
    .section .text.sec0000
    addi          x30, x0, 1269
    jal           x6, 3320

    /* Section 1 (addresses [0x02d4..0x0333]) */
    .section .text.sec0001
    lui           x29, 29447
    srl           x18, x30, x30
    slli          x17, x24, 5
    ori           x16, x17, -1155
    or            x3, x16, x29
    sub           x25, x18, x29
    or            x6, x6, x0
    lui           x21, 273100
    and           x25, x24, x24
    ...

and gen.ld looks something like this:

    SECTIONS
    {
        /* Section 0 (addresses [0x0000..0x0007]) */
        .text.sec0000 0x0 : AT(0x100000)
        {
            *(.text.sec0000)
        }

        /* Section 1 (addresses [0x02d4..0x0333]) */
        .text.sec0001 0x2d4 : AT(0x1002d4)
        {
            *(.text.sec0001)
        }
    ...

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
3 files changed
tree: a06b803d2d1fc9afe8929cdff0c695117b916b9c
  1. .github/
  2. ci/
  3. doc/
  4. hw/
  5. site/
  6. sw/
  7. test/
  8. util/
  9. .clang-format
  10. .dockerignore
  11. .flake8
  12. .gitignore
  13. .style.yapf
  14. _index.md
  15. apt-requirements.txt
  16. azure-pipelines.yml
  17. check_tool_requirements.core
  18. CLA
  19. COMMITTERS
  20. CONTRIBUTING.md
  21. LICENSE
  22. meson.build
  23. meson_init.sh
  24. meson_options.txt
  25. python-requirements.txt
  26. README.md
  27. tool_requirements.py
  28. toolchain.txt
README.md

OpenTitan

OpenTitan logo

About the project

OpenTitan is an open source silicon Root of Trust (RoT) project. OpenTitan will make the silicon RoT design and implementation more transparent, trustworthy, and secure for enterprises, platform providers, and chip manufacturers. OpenTitan is administered by lowRISC CIC as a collaborative project to produce high quality, open IP for instantiation as a full-featured product. See the OpenTitan site and OpenTitan docs for more information about the project.

About this repository

This repository contains hardware, software and utilities written as part of the OpenTitan project. It is structured as monolithic repository, or “monorepo”, where all components live in one repository. It exists to enable collaboration across partners participating in the OpenTitan project.

Documentation

The project contains comprehensive documentation of all IPs and tools. You can access it online at docs.opentitan.org.

How to contribute

Have a look at CONTRIBUTING for guidelines on how to contribute code to this repository.

Licensing

Unless otherwise noted, everything in this repository is covered by the Apache License, Version 2.0 (see LICENSE for full text).