Fix linker tests to work with 16-bit targets.

PR 25829
	* testsuite/ld-scripts/script.exp (check_script)
	(extract_symbol_test): Make test addresses fit in 16 bits.
	* testsuite/ld-scripts/memory.t: Likewise.
	* testsuite/ld-scripts/memory_sym.t (TXT_LENGTH): Likewise.
	* testsuite/ld-scripts/default-script.t (_START): Likewise.
	* testsuite/ld-scripts/default-script1.d: Likewise.
	* testsuite/ld-scripts/default-script2.d: Likewise.
	* testsuite/ld-scripts/default-script3.d: Likewise.
	* testsuite/ld-scripts/default-script4.d: Likewise.
	* testsuite/ld-scripts/empty-address-1.t: Likewise.
	* testsuite/ld-scripts/empty-address-1.d: Likewise.
	* testsuite/ld-scripts/empty-address-2a.d: Likewise.
	* testsuite/ld-scripts/empty-address-2b.d: Likewise.
	* testsuite/ld-misc/start.s: .long -> .dc.a to allow relocation to
	fit target address size.
 	* testsuite/ld-scripts/empty-address-1.s: Likewise.
	* testsuite/ld-scripts/empty-address-2.s: Likewise.
This commit is contained in:
Stephen Casner 2020-04-21 15:10:52 +01:00 committed by Nick Clifton
parent d89edf9b81
commit 39a7b38fac
16 changed files with 60 additions and 31 deletions

View File

@ -1,3 +1,24 @@
2020-04-21 Stephen Casner <casner@acm.org>
PR 25829
* testsuite/ld-scripts/script.exp (check_script)
(extract_symbol_test): Make test addresses fit in 16 bits.
* testsuite/ld-scripts/memory.t: Likewise.
* testsuite/ld-scripts/memory_sym.t (TXT_LENGTH): Likewise.
* testsuite/ld-scripts/default-script.t (_START): Likewise.
* testsuite/ld-scripts/default-script1.d: Likewise.
* testsuite/ld-scripts/default-script2.d: Likewise.
* testsuite/ld-scripts/default-script3.d: Likewise.
* testsuite/ld-scripts/default-script4.d: Likewise.
* testsuite/ld-scripts/empty-address-1.t: Likewise.
* testsuite/ld-scripts/empty-address-1.d: Likewise.
* testsuite/ld-scripts/empty-address-2a.d: Likewise.
* testsuite/ld-scripts/empty-address-2b.d: Likewise.
* testsuite/ld-misc/start.s: .long -> .dc.a to allow relocation to
fit target address size.
* testsuite/ld-scripts/empty-address-1.s: Likewise.
* testsuite/ld-scripts/empty-address-2.s: Likewise.
2020-04-21 H.J. Lu <hongjiu.lu@intel.com> 2020-04-21 H.J. Lu <hongjiu.lu@intel.com>
PR ld/25849 PR ld/25849

View File

@ -7,4 +7,4 @@ _start:
__start: __start:
.global main /* Used by HPPA targets. */ .global main /* Used by HPPA targets. */
main: main:
.long foo .dc.a foo

View File

@ -1,4 +1,4 @@
_START = DEFINED(_START) ? _START : 0x9000000; _START = DEFINED(_START) ? _START : 0x900;
SECTIONS SECTIONS
{ {
. = _START; . = _START;

View File

@ -1,9 +1,11 @@
# source: default-script.s # source: default-script.s
# ld: -defsym _START=0x8000000 -T default-script.t # ld: -defsym _START=0x800 -T default-script.t
# nm: -n # nm: -n
# skip: *-*-mingw64 x86_64-*-cygwin
# Skipped on Mingw64 and Cygwin because the image base defaults to 0x100000000
#... #...
0*8000000 . _START 0*800 . _START
#... #...
0*8000000 T text 0*800 T text
#pass #pass

View File

@ -1,9 +1,11 @@
# source: default-script.s # source: default-script.s
# ld: -T default-script.t -defsym _START=0x8000000 # ld: -T default-script.t -defsym _START=0x800
# nm: -n # nm: -n
# skip: *-*-mingw64 x86_64-*-cygwin
# Skipped on Mingw64 and Cygwin because the image base defaults to 0x100000000
#... #...
0*8000000 . _START 0*800 . _START
#... #...
0*9000000 T text 0*900 T text
#pass #pass

View File

@ -1,9 +1,11 @@
# source: default-script.s # source: default-script.s
# ld: -defsym _START=0x8000000 -dT default-script.t # ld: -defsym _START=0x800 -dT default-script.t
# nm: -n # nm: -n
# skip: *-*-mingw64 x86_64-*-cygwin
# Skipped on Mingw64 and Cygwin because the image base defaults to 0x100000000
#... #...
0*8000000 . _START 0*800 . _START
#... #...
0*8000000 T text 0*800 T text
#pass #pass

View File

@ -1,9 +1,11 @@
# source: default-script.s # source: default-script.s
# ld: --default-script default-script.t -defsym _START=0x8000000 # ld: --default-script default-script.t -defsym _START=0x800
# nm: -n # nm: -n
# skip: *-*-mingw64 x86_64-*-cygwin
# Skipped on Mingw64 and Cygwin because the image base defaults to 0x100000000
#... #...
0*8000000 . _START 0*800 . _START
#... #...
0*8000000 T text 0*800 T text
#pass #pass

View File

@ -2,8 +2,8 @@
#nm: -n #nm: -n
#xfail: frv-*-*linux* #xfail: frv-*-*linux*
#... #...
0+0 T _start 0+0 [AT] _start
#... #...
0+2000000 [ADT] __data_end 0+200 [ADT] __data_end
0+2000000 [ADT] __data_start 0+200 [ADT] __data_start
#pass #pass

View File

@ -1,5 +1,5 @@
.text .text
.global _start .global _start
_start: _start:
.long __data_start .dc.a __data_start
.long __data_end .dc.a __data_end

View File

@ -1,7 +1,7 @@
SECTIONS SECTIONS
{ {
.text 0x0000000: { *(.text) } .text 0x0000000: { *(.text) }
.data 0x2000000: .data 0x200:
{ {
__data_start = . ; __data_start = . ;
*(.data) *(.data)

View File

@ -1,5 +1,5 @@
.text .text
.global _start .global _start
_start: _start:
.long __data_end .dc.a __data_end
.p2align 4 .p2align 4

View File

@ -1,7 +1,7 @@
#source: empty-address-2.s #source: empty-address-2.s
#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2a.t #ld: -Ttext 0x0000000 -Tdata 0x200 -T empty-address-2a.t
#nm: -n #nm: -n
#xfail: frv-*-*linux* #xfail: frv-*-*linux* riscv64-*-*
#... #...
0+0 T _start 0+0 T _start
#... #...

View File

@ -1,7 +1,7 @@
#source: empty-address-2.s #source: empty-address-2.s
#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2b.t #ld: -Ttext 0x0000000 -Tdata 0x200 -T empty-address-2b.t
#nm: -n #nm: -n
#xfail: frv-*-*linux* #xfail: frv-*-*linux* riscv64-*-*
#... #...
0+0 T _start 0+0 T _start
#... #...

View File

@ -1,7 +1,7 @@
MEMORY MEMORY
{ {
R_TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 32K R_TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 16K
R_DATAMEM (AW) : org = 0x1000, l = (64 * 1024) R_DATAMEM (AW) : org = 0x1000, l = (4 * 1024)
} }
REGION_ALIAS ("A_TEXTMEM", R_TEXTMEM); REGION_ALIAS ("A_TEXTMEM", R_TEXTMEM);

View File

@ -1,5 +1,5 @@
TXT_ORIGIN = 0x100; TXT_ORIGIN = 0x100;
TXT_LENGTH = 32K; TXT_LENGTH = 16K;
MEMORY MEMORY
{ {
R_TEXTMEM (ARX) : ORIGIN = TXT_ORIGIN, LENGTH = TXT_LENGTH R_TEXTMEM (ARX) : ORIGIN = TXT_ORIGIN, LENGTH = TXT_LENGTH

View File

@ -67,7 +67,7 @@ proc check_script { } {
} }
if {[info exists nm_output(tred)] \ if {[info exists nm_output(tred)] \
&& $nm_output(tred) != (0x100 + 0x8000)} { && $nm_output(tred) != (0x100 + 0x4000)} {
send_log "tred == $nm_output(tred)\n" send_log "tred == $nm_output(tred)\n"
verbose "tred == $nm_output(tred)" verbose "tred == $nm_output(tred)"
set passes 0 set passes 0
@ -87,7 +87,7 @@ proc check_script { } {
} }
if {[info exists nm_output(fred)] \ if {[info exists nm_output(fred)] \
&& $nm_output(fred) != (0x1000 + 0x10000)} { && $nm_output(fred) != (0x1000 + 0x1000)} {
send_log "fred == $nm_output(fred)\n" send_log "fred == $nm_output(fred)\n"
verbose "fred == $nm_output(fred)" verbose "fred == $nm_output(fred)"
set passes 0 set passes 0
@ -215,7 +215,7 @@ if ![ld_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script
} }
set testname "MEMORY with symbols" set testname "MEMORY with symbols"
if ![ld_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] { if ![ld_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x1000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
fail $testname fail $testname
untested "extract symbols" untested "extract symbols"
} else { } else {