summaryrefslogtreecommitdiff
path: root/tools/elf2efi.lds
blob: 805efc156d14886b4cf0313aee124960efe30d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SECTIONS {
        __ImageBase = .;

        /* We skip the first page because the space will be occupied by the PE headers after conversion. */
        . = CONSTANT(MAXPAGESIZE);
        .text ALIGN(CONSTANT(MAXPAGESIZE)) : {
                *(.text .text.*)
        }
        .rodata ALIGN(CONSTANT(MAXPAGESIZE)) : {
                *(.rodata .rodata.*)
                *(.srodata .srodata.*)
        }
        .data ALIGN(CONSTANT(MAXPAGESIZE)) : {
                *(.data .data.*)
                *(.sdata .sdata.*)
                *(.got .got.*)
                *(.got.plt .got.plt.*)

                /* EDK2 says some firmware cannot handle BSS sections properly. */
                *(.bss .bss.*)
                *(.sbss .sbss.*)
                *(COMMON)
        }

        .sdmagic ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.sdmagic) }
        .osrel   ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.osrel) }
        .sbat    ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.sbat) }

        /* These are used for PE conversion and then discarded. */
        .dynsym   : { *(.dynsym) }
        .dynstr   : { *(.dynstr) }
        .dynamic  : { *(.dynamic) }
        .rel.dyn  : { *(.rel.dyn) }
        .rela.dyn : { *(.rela.dyn) }

        /* These aren't needed and could be discarded. Just in case that they're useful to the debugger
         * we keep them, but move them out of the way to keep the PE binary more compact. */
        .ARM.exidx         : { *(.ARM.exidx) }
        .eh_frame          : { *(.eh_frame) }
        .eh_frame_hdr      : { *(.eh_frame_hdr) }
        .gnu.hash          : { *(.gnu.hash) }
        .hash              : { *(.hash) }
        .note.gnu.build-id : { *(.note.gnu.build-id ) }

        /DISCARD/ : {
                *(.ARM.attributes)
                *(.comment)
                *(.note.*)
                *(.riscv.attributes)
        }
}