|
3 | 3 |
|
4 | 4 | # RUN: ld.lld -o %t.out %t --oformat binary
|
5 | 5 | # RUN: od -t x1 -v %t.out | FileCheck %s
|
6 |
| -# CHECK: 000000 90 11 22 00 00 00 00 00 |
7 |
| -# CHECK-NOT: 00000010 |
| 6 | +# CHECK: 0000000 90 11 22 |
| 7 | +# CHECK-NEXT: 0000003 |
8 | 8 |
|
9 | 9 | ## Check case when linkerscript is used.
|
10 | 10 | # RUN: echo "SECTIONS { . = 0x1000; }" > %t.script
|
|
15 | 15 | # RUN: ld.lld -o %t2.out --script %t.script %t --oformat binary
|
16 | 16 | # RUN: od -t x1 -v %t2.out | FileCheck %s
|
17 | 17 |
|
| 18 | +## LMA(.text)=0x100, LMA(.mysec)=0x108. The minimum LMA of all non-empty sections is 0x100. |
| 19 | +## We place an output section at its LMA minus 0x100. |
| 20 | +# RUN: echo 'SECTIONS { .text 0x100 : {*(.text)} .mysec ALIGN(8) : {*(.mysec*)} }' > %talign.lds |
| 21 | +# RUN: ld.lld -T %talign.lds %t --oformat binary -o %talign |
| 22 | +# RUN: od -Ax -t x1 %talign | FileCheck %s --check-prefix=ALIGN --ignore-case |
| 23 | + |
| 24 | +# ALIGN: 000000 90 00 00 00 00 00 00 00 11 22 |
| 25 | +# ALIGN-NEXT: 00000a |
| 26 | + |
| 27 | +## The empty section .data is ignored when computing the file size. |
| 28 | +# RUN: echo 'SECTIONS { .text : {*(.text .mysec*)} .data 0x100 : {keep = .;}}' > %tempty.lds |
| 29 | +# RUN: ld.lld -T %tempty.lds %t --oformat binary -o %tempty |
| 30 | +# RUN: od -t x1 %tempty | FileCheck %s |
| 31 | + |
| 32 | +## NOBITS sections are ignored as well. |
| 33 | +# RUN: echo 'SECTIONS { .text : {*(.text .mysec*)} .data 0x100 (NOLOAD) : {BYTE(0)}}' > %tnobits.lds |
| 34 | +# RUN: ld.lld -T %tnobits.lds %t --oformat binary -o %tnobits |
| 35 | +# RUN: od -t x1 %tnobits | FileCheck %s |
| 36 | + |
| 37 | +## FIXME .mysec should be placed at file offset 1. |
| 38 | +## This does not work because for a section without PT_LOAD, we consider LMA = VMA. |
| 39 | +# RUN: echo 'SECTIONS { .text : {*(.text)} .mysec 0x8 : AT(1) {*(.mysec*)} }' > %tlma.lds |
| 40 | +# RUN: ld.lld -T %tlma.lds %t --oformat binary -o %tlma |
| 41 | +# RUN: od -Ax -t x1 %tlma | FileCheck %s --check-prefix=ALIGN --ignore-case |
| 42 | + |
18 | 43 | # RUN: not ld.lld -o /dev/null %t --oformat foo 2>&1 \
|
19 | 44 | # RUN: | FileCheck %s --check-prefix ERR
|
20 | 45 | # ERR: unknown --oformat value: foo
|
|
0 commit comments