blob: 5c756a262996a6651a6370b06d459a14c121609f [file] [log] [blame]
Sam Elliott120c7372020-11-03 15:14:46 +00001/* Copyright lowRISC contributors. */
2/* Licensed under the Apache License, Version 2.0, see LICENSE for details. */
3/* SPDX-License-Identifier: Apache-2.0 */
4
5/**
6 * Partial Linker Script for OpenTitan Device Executables
7 *
8 * This Linker Script controls all the sections that we need in the ELF file for
9 * a device executable, but which are not mapped into memory or otherwise
10 * allocated on the device itself.
11 *
12 * These contain amongst other things:
13 * - debugging information needed by DV logging,
14 * - DWARF Sections
15 * - RISC-V Attributes sections
16 *
17 * This is also where we specify the sections to discard, because it is a common
18 * file between all our other linker scripts.
19 *
20 * This partial linker script requires the main linker script to define the
21 * following symbols:
22 * - _dv_log_offset
23 */
24
25/*
26 * Start DV Sections.
27 *
28 * The following sections are used by DV to implement logging in an
29 * alternate way, which enables simulation speed up by completely avoiding
30 * any string format processing or even the actual transmission of log data
31 * to a real peripheral.
32 *
33 * These sections are marked as dummy so that they can still be extracted
34 * using readelf or similar utilities. As such, the content in these sections
35 * is not relevant for the actual SW code and can be safely discarded.
36 */
37
38/**
39 * The following section contains log fields constructed from the logs using
40 * the log_fields_t struct defined in sw/device/lib/runtime/log.h. The size of
41 * each log field is fixed - 20 bytes.
42 */
43.logs.fields _dv_log_offset (INFO): {
44 *(.logs.fields)
45}
46
47/*
48 * End DV Sections
49 */
50
51/* ELF-internal Sections. */
52.symtab 0x0 : { *(.symtab) }
53.strtab 0x0 : { *(.strtab) }
54.shstrtab 0x0 : { *(.shstrtab) }
55
56/* Preserve RISC-V Attributes */
57.riscv.attributes 0x0 : { *(.riscv.attributes) }
58
59/* Preserve Debug Info in ELF Files */
60.debug_info 0x0 : { *(.debug_info) }
61.debug_abbrev 0x0 : { *(.debug_abbrev) }
62.debug_aranges 0x0 : { *(.debug_aranges) }
63.debug_line 0x0 : { *(.debug_line) }
64.debug_loc 0x0 : { *(.debug_loc) }
65.debug_ranges 0x0 : { *(.debug_ranges) }
66.debug_str 0x0 : { *(.debug_str) }
67.debug_frame 0x0 : { *(.debug_frame) }
68
69/* Discarded Sections (Not needed in device images). */
70/DISCARD/ : {
71 /* We don't keep unwind information */
72 *(.eh_frame)
73 *(.eh_frame_hdr)
74
75 /* Compiler Information */
76 *(.comment)
77 *(.comment.*)
78
79 /* Other Notes */
80 *(.note)
81 *(.note.*)
82
83 /* Relocations */
84 *(.rela.*)
85 *(.rela.dyn)
86
87 /* STAB Debugging Info - We Use DWARF */
88 *(.stab)
89 *(.stab.*)
90 *(.stabstr)
91}