xref: /llvm-project/lld/test/ELF/linkerscript/memory-nonalloc.test (revision 66691de94cd7b7b5d2d9ae1d12e99259a8eae5b1)
1REQUIRES: x86
2
3RUN: split-file %s %ts
4RUN: llvm-mc -filetype=obj -triple=x86_64 %ts/s -o %t.o
5
6## Check that a non-allocatable section is not assigned to a memory region by
7## matching the section/region properties. Previously, that could lead to an
8## "error: section '.nonalloc' will not fit in region 'RAM'".
9
10RUN: ld.lld %t.o -T %ts/t --fatal-warnings -o /dev/null
11
12## Check that an explicit assignment is ignored for a non-allocatable section.
13## Previously, that also could lead to the same error.
14
15RUN: ld.lld %t.o -T %ts/t2 -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
16
17WARN: warning: ignoring memory region assignment for non-allocatable section '.nonalloc'
18
19#--- s
20  .global _start
21_start:
22
23  ## Note: a "writable" section is used because lld does not fully support
24  ## memory region attribute "r" at the moment.
25  .section .nonalloc,"w"
26  .zero 0x1000
27
28#--- t
29MEMORY
30{
31  RAM (rwx) : ORIGIN = 0x8000, LENGTH = 0x100
32}
33
34SECTIONS
35{
36  .nonalloc : { *(.nonalloc) }
37}
38
39#--- t2
40MEMORY
41{
42  RAM (rwx) : ORIGIN = 0x8000, LENGTH = 0x100
43}
44
45SECTIONS
46{
47  .nonalloc : { *(.nonalloc) } > RAM
48}
49