|
1 | 1 | # REQUIRES: x86 |
2 | 2 | # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o |
| 3 | +# RUN: not ld.lld %t.o --section-start .text=0x100000 \ |
| 4 | +# RUN: --section-start=.data=0x110000 --section-start .bss=0x200000 |
3 | 5 | # RUN: ld.lld %t.o --section-start .text=0x100000 \ |
4 | | -# RUN: --section-start=.data=0x110000 --section-start .bss=0x200000 -o %t |
| 6 | +# RUN: --section-start=.data=0x110000 --section-start .bss=0x200000 --noinhibit-exec -o %t 2>&1 | \ |
| 7 | +# RUN: FileCheck %s --check-prefix=LINK --implicit-check-not=warning: |
5 | 8 | # RUN: llvm-objdump --section-headers %t | FileCheck %s |
6 | 9 |
|
| 10 | +# LINK: warning: section '.text' address (0x100000) is smaller than image base (0x200000); specify --image-base |
| 11 | +# LINK-NEXT: warning: section '.data' address (0x110000) is smaller than image base (0x200000); specify --image-base |
| 12 | + |
7 | 13 | # CHECK: Sections: |
8 | 14 | # CHECK-NEXT: Idx Name Size VMA Type |
9 | 15 | # CHECK-NEXT: 0 00000000 0000000000000000 |
10 | 16 | # CHECK-NEXT: 1 .text 00000001 0000000000100000 TEXT |
11 | 17 | # CHECK-NEXT: 2 .data 00000004 0000000000110000 DATA |
12 | 18 | # CHECK-NEXT: 3 .bss 00000004 0000000000200000 BSS |
13 | 19 |
|
14 | | -## The same, but dropped "0x" prefix. |
15 | | -# RUN: ld.lld %t.o --section-start .text=100000 \ |
16 | | -# RUN: --section-start .data=110000 --section-start .bss=0x200000 -o %t1 |
| 20 | +## The errors go away when the image base is 0. |
| 21 | +# RUN: ld.lld %t.o -pie --section-start .text=0x100000 \ |
| 22 | +# RUN: --section-start=.data=0x110000 --section-start .bss=0x200000 -o %t 2>&1 | count 0 |
| 23 | +# RUN: llvm-objdump --section-headers %t | FileCheck %s |
| 24 | + |
| 25 | +## The same, but dropped "0x" prefix. Specify a smaller --image-base to suppress warnings. |
| 26 | +# RUN: ld.lld %t.o --image-base=0x90000 --section-start .text=100000 \ |
| 27 | +# RUN: --section-start .data=110000 --section-start .bss=0x200000 -o %t1 2>&1 | count 0 |
17 | 28 | # RUN: llvm-objdump --section-headers %t1 | FileCheck %s |
18 | 29 |
|
19 | 30 | ## Use -Ttext, -Tdata, -Tbss as replacement for --section-start: |
20 | | -# RUN: ld.lld %t.o -Ttext=0x100000 -Tdata=0x110000 -Tbss=0x200000 -o %t4 |
| 31 | +# RUN: ld.lld %t.o --image-base=0x90000 -Ttext=0x100000 -Tdata=0x110000 -Tbss=0x200000 -o %t4 |
21 | 32 | # RUN: llvm-objdump --section-headers %t4 | FileCheck %s |
22 | 33 |
|
23 | 34 | ## The same, but dropped "0x" prefix. |
24 | | -# RUN: ld.lld %t.o -Ttext=100000 -Tdata=110000 -Tbss=200000 -o %t5 |
| 35 | +# RUN: ld.lld %t.o --image-base=0x90000 -Ttext=100000 -Tdata=110000 -Tbss=200000 -o %t5 |
25 | 36 | # RUN: llvm-objdump --section-headers %t5 | FileCheck %s |
26 | 37 |
|
27 | 38 | ## Check form without assignment: |
28 | | -# RUN: ld.lld %t.o -Ttext 0x100000 -Tdata 0x110000 -Tbss 0x200000 -o %t4 |
| 39 | +# RUN: ld.lld %t.o --image-base=0x90000 -Ttext 0x100000 -Tdata 0x110000 -Tbss 0x200000 -o %t4 |
29 | 40 | # RUN: llvm-objdump --section-headers %t4 | FileCheck %s |
30 | 41 |
|
31 | 42 | ## Errors: |
|
0 commit comments