2016-09-14 21:07:13 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
|
|
|
# RUN: ld.lld %t.o --section-start .text=0x100000 \
|
2018-03-02 07:06:10 +08:00
|
|
|
# RUN: --section-start=.data=0x110000 --section-start .bss=0x200000 -o %t
|
2016-09-14 21:07:13 +08:00
|
|
|
# RUN: llvm-objdump -section-headers %t | FileCheck %s
|
|
|
|
|
|
|
|
# CHECK: Sections:
|
2019-01-28 23:03:47 +08:00
|
|
|
# CHECK-NEXT: Idx Name Size VMA Type
|
2016-09-14 21:07:13 +08:00
|
|
|
# CHECK-NEXT: 0 00000000 0000000000000000
|
2018-06-23 08:15:23 +08:00
|
|
|
# CHECK-NEXT: 1 .text 00000001 0000000000100000 TEXT
|
2016-09-14 21:07:13 +08:00
|
|
|
# CHECK-NEXT: 2 .data 00000004 0000000000110000 DATA
|
|
|
|
# CHECK-NEXT: 3 .bss 00000004 0000000000200000 BSS
|
|
|
|
|
|
|
|
## The same, but dropped "0x" prefix.
|
|
|
|
# RUN: ld.lld %t.o --section-start .text=100000 \
|
|
|
|
# RUN: --section-start .data=110000 --section-start .bss=0x200000 -o %t1
|
|
|
|
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
|
|
|
|
|
|
|
|
## Use -Ttext, -Tdata, -Tbss as replacement for --section-start:
|
|
|
|
# RUN: ld.lld %t.o -Ttext=0x100000 -Tdata=0x110000 -Tbss=0x200000 -o %t4
|
|
|
|
# RUN: llvm-objdump -section-headers %t4 | FileCheck %s
|
|
|
|
|
|
|
|
## The same, but dropped "0x" prefix.
|
|
|
|
# RUN: ld.lld %t.o -Ttext=100000 -Tdata=110000 -Tbss=200000 -o %t5
|
|
|
|
# RUN: llvm-objdump -section-headers %t5 | FileCheck %s
|
|
|
|
|
2016-11-03 00:06:00 +08:00
|
|
|
## Check form without assignment:
|
|
|
|
# RUN: ld.lld %t.o -Ttext 0x100000 -Tdata 0x110000 -Tbss 0x200000 -o %t4
|
|
|
|
# RUN: llvm-objdump -section-headers %t4 | FileCheck %s
|
|
|
|
|
2016-09-14 21:07:13 +08:00
|
|
|
## Errors:
|
2018-07-03 01:48:23 +08:00
|
|
|
# RUN: not ld.lld %t.o --section-start .text100000 -o /dev/null 2>&1 \
|
2016-09-14 21:07:13 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=ERR1 %s
|
|
|
|
# ERR1: invalid argument: --section-start .text100000
|
|
|
|
|
2018-07-03 01:48:23 +08:00
|
|
|
# RUN: not ld.lld %t.o --section-start .text=1Q0000 -o /dev/null 2>&1 \
|
2016-09-14 21:07:13 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=ERR2 %s
|
|
|
|
# ERR2: invalid argument: --section-start .text=1Q0000
|
|
|
|
|
|
|
|
# RUN: not ld.lld %t.o -Ttext=1w0000 -o %t6 2>&1 \
|
|
|
|
# RUN: | FileCheck -check-prefix=ERR3 %s
|
Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics
With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid
value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value
'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl
flags produce much less confusing output as well.
Fixes PR29106.
Since an arg and its alias can have different arg types (joined vs not)
and different values (because of AliasArgs<>), I chose to give the Alias
its own Arg object. For convenience, I just store the alias directly in
the unaliased arg – there aren't many arg objects at runtime, so that
seems ok.
Finally, I changed Arg::getAsString() to use the alias's representation
if it's present – that function was already documented as being the
suitable function for diagnostics, and most callers already used it for
diagnostics.
Implementation-wise, Arg::accept() previously used to parse things as
the unaliased option. The core of that switch is now extracted into a
new function acceptInternal() which parses as the _aliased_ option, and
the previously-intermingled unaliasing is now done as an explicit step
afterwards.
(This also changes one place in lld that didn't use getAsString() for
diagnostics, so that that one place now also prints the flag as the user
wrote it, not as it looks after it went through unaliasing.)
Differential Revision: https://reviews.llvm.org/D64253
llvm-svn: 365413
2019-07-09 08:34:08 +08:00
|
|
|
# ERR3: invalid argument: -Ttext=1w0000
|
2016-09-14 21:07:13 +08:00
|
|
|
|
|
|
|
# RUN: not ld.lld %t.o -Tbss=1w0000 -o %t6 2>&1 \
|
|
|
|
# RUN: | FileCheck -check-prefix=ERR4 %s
|
Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics
With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid
value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value
'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl
flags produce much less confusing output as well.
Fixes PR29106.
Since an arg and its alias can have different arg types (joined vs not)
and different values (because of AliasArgs<>), I chose to give the Alias
its own Arg object. For convenience, I just store the alias directly in
the unaliased arg – there aren't many arg objects at runtime, so that
seems ok.
Finally, I changed Arg::getAsString() to use the alias's representation
if it's present – that function was already documented as being the
suitable function for diagnostics, and most callers already used it for
diagnostics.
Implementation-wise, Arg::accept() previously used to parse things as
the unaliased option. The core of that switch is now extracted into a
new function acceptInternal() which parses as the _aliased_ option, and
the previously-intermingled unaliasing is now done as an explicit step
afterwards.
(This also changes one place in lld that didn't use getAsString() for
diagnostics, so that that one place now also prints the flag as the user
wrote it, not as it looks after it went through unaliasing.)
Differential Revision: https://reviews.llvm.org/D64253
llvm-svn: 365413
2019-07-09 08:34:08 +08:00
|
|
|
# ERR4: invalid argument: -Tbss=1w0000
|
2016-09-14 21:07:13 +08:00
|
|
|
|
|
|
|
# RUN: not ld.lld %t.o -Tdata=1w0000 -o %t6 2>&1 \
|
|
|
|
# RUN: | FileCheck -check-prefix=ERR5 %s
|
Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics
With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid
value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value
'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl
flags produce much less confusing output as well.
Fixes PR29106.
Since an arg and its alias can have different arg types (joined vs not)
and different values (because of AliasArgs<>), I chose to give the Alias
its own Arg object. For convenience, I just store the alias directly in
the unaliased arg – there aren't many arg objects at runtime, so that
seems ok.
Finally, I changed Arg::getAsString() to use the alias's representation
if it's present – that function was already documented as being the
suitable function for diagnostics, and most callers already used it for
diagnostics.
Implementation-wise, Arg::accept() previously used to parse things as
the unaliased option. The core of that switch is now extracted into a
new function acceptInternal() which parses as the _aliased_ option, and
the previously-intermingled unaliasing is now done as an explicit step
afterwards.
(This also changes one place in lld that didn't use getAsString() for
diagnostics, so that that one place now also prints the flag as the user
wrote it, not as it looks after it went through unaliasing.)
Differential Revision: https://reviews.llvm.org/D64253
llvm-svn: 365413
2019-07-09 08:34:08 +08:00
|
|
|
# ERR5: invalid argument: -Tdata=1w0000
|
2016-09-14 21:07:13 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.data
|
|
|
|
.long 0
|
|
|
|
|
|
|
|
.bss
|
|
|
|
.zero 4
|