xref: /DragonBoot/src/arch/riscv64/link.ld (revision 0ec3a34a58ffc0a9c51a23a7ee5e7d803a0060cd)
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * U-Boot riscv64 EFI linker script
4 *
5 * SPDX-License-Identifier:     BSD-2-Clause
6 *
7 * Modified from arch/arm/lib/elf_aarch64_efi.lds
8 */
9/**
10 * Sourced from
11 * https://source.denx.de/u-boot/u-boot/-/blob/52ba373b7825e9feab8357065155cf43dfe2f4ff/arch/riscv/lib/elf_riscv64_efi.lds
12 */
13
14OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
15OUTPUT_ARCH(riscv)
16ENTRY(_start)
17SECTIONS
18{
19        .text 0x0 : SUBALIGN(16) {
20                _text = .;
21                *(.text.head)
22                *(.text)
23                *(.text.*)
24                *(.gnu.linkonce.t.*)
25                *(.srodata)
26                *(.rodata*)
27                *(.got)
28                *(.got.*)
29                . = ALIGN(16);
30        }
31
32        _etext = .;
33        . = ALIGN(16);
34        _text_size = . - _text;
35        .dynamic  : { *(.dynamic) }
36        .data : {
37                _data = .;
38                *(.sdata)
39                *(.sdata.*)
40                *(.data)
41                *(.data1)
42                *(.data.*)
43                *(.got.plt)
44                *(.got.plt.*)
45
46
47                /*
48                 * The EFI loader doesn't seem to like a .bss section, so we
49                 * stick it all into .data:
50                 */
51                . = ALIGN(16);
52                _bss = .;
53                *(.sbss)
54                *(.scommon)
55                *(.dynbss)
56                *(.bss)
57
58                *(.bss.*)
59                *(COMMON)
60                . = ALIGN(16);
61                _bss_end = .;
62        }
63
64        .rela (INFO) : {
65            *(.rela .rela*)
66        }
67
68
69        /*
70         * Put _edata here so it all gets loaded by U-Boot.
71         * The script originally had this equal to _bss_end, but
72         * our .rela.dyn wasn't getting loaded into memory so we
73         * couldn't do any relocations.
74         *
75         * Here be dragons.  Do we need .dynsym/.dynstr too?
76         */
77        _edata = .;
78        _data_size = . - _etext;
79
80        . = ALIGN(4096);
81        .dynsym   : { *(.dynsym) }
82        . = ALIGN(4096);
83        .dynstr   : { *(.dynstr) }
84        . = ALIGN(4096);
85        .note.gnu.build-id : { *(.note.gnu.build-id) }
86        /DISCARD/ : {
87
88                *(.eh_frame)
89                *(.note.GNU-stack)
90        }
91        .comment 0 : { *(.comment) }
92}
93