From: Stephen Casner Date: Tue, 21 Apr 2020 14:10:52 +0000 (+0100) Subject: Fix linker tests to work with 16-bit targets. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=39a7b38fac0e;p=binutils-gdb.git 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. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 1169f93373e..0ef2c7bb990 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,24 @@ +2020-04-21 Stephen Casner + + 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 PR ld/25849 diff --git a/ld/testsuite/ld-misc/start.s b/ld/testsuite/ld-misc/start.s index 846236eef4d..b01c5591774 100644 --- a/ld/testsuite/ld-misc/start.s +++ b/ld/testsuite/ld-misc/start.s @@ -7,4 +7,4 @@ _start: __start: .global main /* Used by HPPA targets. */ main: - .long foo + .dc.a foo diff --git a/ld/testsuite/ld-scripts/default-script.t b/ld/testsuite/ld-scripts/default-script.t index fc70187cd40..ff0fcda7a93 100644 --- a/ld/testsuite/ld-scripts/default-script.t +++ b/ld/testsuite/ld-scripts/default-script.t @@ -1,4 +1,4 @@ -_START = DEFINED(_START) ? _START : 0x9000000; +_START = DEFINED(_START) ? _START : 0x900; SECTIONS { . = _START; diff --git a/ld/testsuite/ld-scripts/default-script1.d b/ld/testsuite/ld-scripts/default-script1.d index 61973f75615..a749265b9f8 100644 --- a/ld/testsuite/ld-scripts/default-script1.d +++ b/ld/testsuite/ld-scripts/default-script1.d @@ -1,9 +1,11 @@ # source: default-script.s -# ld: -defsym _START=0x8000000 -T default-script.t +# ld: -defsym _START=0x800 -T default-script.t # 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 diff --git a/ld/testsuite/ld-scripts/default-script2.d b/ld/testsuite/ld-scripts/default-script2.d index 68ce2aa9fe2..137cf09b529 100644 --- a/ld/testsuite/ld-scripts/default-script2.d +++ b/ld/testsuite/ld-scripts/default-script2.d @@ -1,9 +1,11 @@ # source: default-script.s -# ld: -T default-script.t -defsym _START=0x8000000 +# ld: -T default-script.t -defsym _START=0x800 # 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 diff --git a/ld/testsuite/ld-scripts/default-script3.d b/ld/testsuite/ld-scripts/default-script3.d index b2da49654b2..00f64ecb618 100644 --- a/ld/testsuite/ld-scripts/default-script3.d +++ b/ld/testsuite/ld-scripts/default-script3.d @@ -1,9 +1,11 @@ # source: default-script.s -# ld: -defsym _START=0x8000000 -dT default-script.t +# ld: -defsym _START=0x800 -dT default-script.t # 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 diff --git a/ld/testsuite/ld-scripts/default-script4.d b/ld/testsuite/ld-scripts/default-script4.d index 001008447ab..dc4f33b37cb 100644 --- a/ld/testsuite/ld-scripts/default-script4.d +++ b/ld/testsuite/ld-scripts/default-script4.d @@ -1,9 +1,11 @@ # source: default-script.s -# ld: --default-script default-script.t -defsym _START=0x8000000 +# ld: --default-script default-script.t -defsym _START=0x800 # 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 diff --git a/ld/testsuite/ld-scripts/empty-address-1.d b/ld/testsuite/ld-scripts/empty-address-1.d index 5b18217639c..c758b968f0b 100644 --- a/ld/testsuite/ld-scripts/empty-address-1.d +++ b/ld/testsuite/ld-scripts/empty-address-1.d @@ -2,8 +2,8 @@ #nm: -n #xfail: frv-*-*linux* #... -0+0 T _start +0+0 [AT] _start #... -0+2000000 [ADT] __data_end -0+2000000 [ADT] __data_start +0+200 [ADT] __data_end +0+200 [ADT] __data_start #pass diff --git a/ld/testsuite/ld-scripts/empty-address-1.s b/ld/testsuite/ld-scripts/empty-address-1.s index c5cc1a596c8..7ffe2d53cab 100644 --- a/ld/testsuite/ld-scripts/empty-address-1.s +++ b/ld/testsuite/ld-scripts/empty-address-1.s @@ -1,5 +1,5 @@ .text .global _start _start: - .long __data_start - .long __data_end + .dc.a __data_start + .dc.a __data_end diff --git a/ld/testsuite/ld-scripts/empty-address-1.t b/ld/testsuite/ld-scripts/empty-address-1.t index 57a8bed2771..7c4b8151c7a 100644 --- a/ld/testsuite/ld-scripts/empty-address-1.t +++ b/ld/testsuite/ld-scripts/empty-address-1.t @@ -1,7 +1,7 @@ SECTIONS { .text 0x0000000: { *(.text) } - .data 0x2000000: + .data 0x200: { __data_start = . ; *(.data) diff --git a/ld/testsuite/ld-scripts/empty-address-2.s b/ld/testsuite/ld-scripts/empty-address-2.s index 79f58eacc34..14d35d81c66 100644 --- a/ld/testsuite/ld-scripts/empty-address-2.s +++ b/ld/testsuite/ld-scripts/empty-address-2.s @@ -1,5 +1,5 @@ .text .global _start _start: - .long __data_end + .dc.a __data_end .p2align 4 diff --git a/ld/testsuite/ld-scripts/empty-address-2a.d b/ld/testsuite/ld-scripts/empty-address-2a.d index d27bf0045e0..85aa648531d 100644 --- a/ld/testsuite/ld-scripts/empty-address-2a.d +++ b/ld/testsuite/ld-scripts/empty-address-2a.d @@ -1,7 +1,7 @@ #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 -#xfail: frv-*-*linux* +#xfail: frv-*-*linux* riscv64-*-* #... 0+0 T _start #... diff --git a/ld/testsuite/ld-scripts/empty-address-2b.d b/ld/testsuite/ld-scripts/empty-address-2b.d index eb23e7481f5..9e6bc3d1de0 100644 --- a/ld/testsuite/ld-scripts/empty-address-2b.d +++ b/ld/testsuite/ld-scripts/empty-address-2b.d @@ -1,7 +1,7 @@ #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 -#xfail: frv-*-*linux* +#xfail: frv-*-*linux* riscv64-*-* #... 0+0 T _start #... diff --git a/ld/testsuite/ld-scripts/memory.t b/ld/testsuite/ld-scripts/memory.t index 937394f522f..5b2feb10596 100644 --- a/ld/testsuite/ld-scripts/memory.t +++ b/ld/testsuite/ld-scripts/memory.t @@ -1,7 +1,7 @@ MEMORY { - R_TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 32K - R_DATAMEM (AW) : org = 0x1000, l = (64 * 1024) + R_TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 16K + R_DATAMEM (AW) : org = 0x1000, l = (4 * 1024) } REGION_ALIAS ("A_TEXTMEM", R_TEXTMEM); diff --git a/ld/testsuite/ld-scripts/memory_sym.t b/ld/testsuite/ld-scripts/memory_sym.t index 4ccec550120..c9df2ed28ad 100644 --- a/ld/testsuite/ld-scripts/memory_sym.t +++ b/ld/testsuite/ld-scripts/memory_sym.t @@ -1,5 +1,5 @@ TXT_ORIGIN = 0x100; -TXT_LENGTH = 32K; +TXT_LENGTH = 16K; MEMORY { R_TEXTMEM (ARX) : ORIGIN = TXT_ORIGIN, LENGTH = TXT_LENGTH diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp index 5a01279ade7..eaa4f53b034 100644 --- a/ld/testsuite/ld-scripts/script.exp +++ b/ld/testsuite/ld-scripts/script.exp @@ -67,7 +67,7 @@ proc check_script { } { } if {[info exists nm_output(tred)] \ - && $nm_output(tred) != (0x100 + 0x8000)} { + && $nm_output(tred) != (0x100 + 0x4000)} { send_log "tred == $nm_output(tred)\n" verbose "tred == $nm_output(tred)" set passes 0 @@ -87,7 +87,7 @@ proc check_script { } { } if {[info exists nm_output(fred)] \ - && $nm_output(fred) != (0x1000 + 0x10000)} { + && $nm_output(fred) != (0x1000 + 0x1000)} { send_log "fred == $nm_output(fred)\n" verbose "fred == $nm_output(fred)" 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" -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 untested "extract symbols" } else {