PE image base fallout
Fixes x86_64-w64-mingw32 tests that failed with the recent diagnosis for out of range RVA, and a couple of other gc-sections tests that failed for other reasons. * testsuite/ld-gc/gc.exp: Pass "-image-base 0" to ld for PE, and arrange to define __main for some run_dump_test tests. * testsuite/ld-gc/pr13683.d: Accept more symbols. * testsuite/ld-gc/pr14265.d: Likewise, and ordering. * testsuite/ld-scripts/crossref.exp: Pass "-image-base 0" to ld for PE. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/lib/ld-lib.exp (ld_link_defsyms): Use is_pecoff_format.
This commit is contained in:
parent
1e1e17e5e2
commit
68cb21837f
7 changed files with 53 additions and 21 deletions
10
ld/ChangeLog
10
ld/ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2021-03-12 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* testsuite/ld-gc/gc.exp: Pass "-image-base 0" to ld for PE, and
|
||||||
|
arrange to define __main for some run_dump_test tests.
|
||||||
|
* testsuite/ld-gc/pr13683.d: Accept more symbols.
|
||||||
|
* testsuite/ld-gc/pr14265.d: Likewise, and ordering.
|
||||||
|
* testsuite/ld-scripts/crossref.exp: Pass "-image-base 0" to ld for PE.
|
||||||
|
* testsuite/ld-srec/srec.exp: Likewise.
|
||||||
|
* testsuite/lib/ld-lib.exp (ld_link_defsyms): Use is_pecoff_format.
|
||||||
|
|
||||||
2021-03-11 Nelson Chu <nelson.chu@sifive.com>
|
2021-03-11 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
* emultempl/riscvelf.em (after_allocation): Run ldelf_map_segments
|
* emultempl/riscvelf.em (after_allocation): Run ldelf_map_segments
|
||||||
|
|
|
@ -54,6 +54,9 @@ proc test_gc { testname filename linker ldflags} {
|
||||||
|
|
||||||
set outfile "tmpdir/$filename"
|
set outfile "tmpdir/$filename"
|
||||||
set options "-L$srcdir/$subdir"
|
set options "-L$srcdir/$subdir"
|
||||||
|
if [is_pecoff_format] {
|
||||||
|
append ldflags " --image-base 0"
|
||||||
|
}
|
||||||
append options " " $ldflags " " [ld_link_defsyms] " " $objfile
|
append options " " $ldflags " " [ld_link_defsyms] " " $objfile
|
||||||
|
|
||||||
if ![ld_link $linker $outfile $options] {
|
if ![ld_link $linker $outfile $options] {
|
||||||
|
@ -86,9 +89,13 @@ test_gc "Check --gc-section/-q" "gcrexe" $ld "--gc-sections -q -e main"
|
||||||
test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main"
|
test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main"
|
||||||
test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
|
test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
|
||||||
|
|
||||||
|
set old_ldflags $LDFLAGS
|
||||||
|
if [is_pecoff_format] {
|
||||||
|
append LDFLAGS " --image-base 0"
|
||||||
|
}
|
||||||
set old_asflags $ASFLAGS
|
set old_asflags $ASFLAGS
|
||||||
if [is_underscore_target] {
|
if [is_underscore_target] {
|
||||||
set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
|
append ASFLAGS " --defsym UNDERSCORE=1"
|
||||||
}
|
}
|
||||||
|
|
||||||
run_dump_test "noent"
|
run_dump_test "noent"
|
||||||
|
@ -111,7 +118,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
|
||||||
set gasopt "-mpic -mpid=near"
|
set gasopt "-mpic -mpid=near"
|
||||||
}
|
}
|
||||||
# These targets do not default to linking with shared libraries.
|
# These targets do not default to linking with shared libraries.
|
||||||
set old_ldflags $LDFLAGS
|
set save_ldflags $LDFLAGS
|
||||||
if { [istarget "mips*vr4100*-*-elf*"] \
|
if { [istarget "mips*vr4100*-*-elf*"] \
|
||||||
|| [istarget "mips*vr4300*-*-elf*"] \
|
|| [istarget "mips*vr4300*-*-elf*"] \
|
||||||
|| [istarget "mips*vr5000*-*-elf*"] } {
|
|| [istarget "mips*vr5000*-*-elf*"] } {
|
||||||
|
@ -130,7 +137,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
|
||||||
} else {
|
} else {
|
||||||
run_dump_test "pr20022"
|
run_dump_test "pr20022"
|
||||||
}
|
}
|
||||||
set LDFLAGS $old_ldflags
|
set LDFLAGS $save_ldflags
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [check_compiler_available] } {
|
if { [check_compiler_available] } {
|
||||||
|
@ -144,25 +151,28 @@ if { [check_compiler_available] } {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set symdefs ""
|
||||||
|
if [is_pecoff_format] {
|
||||||
|
set symdefs {{ld {--defsym __main=main --defsym ___main=main}}}
|
||||||
|
}
|
||||||
|
|
||||||
if { [check_compiler_available] } {
|
if { [check_compiler_available] } {
|
||||||
ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
|
ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
|
||||||
run_dump_test "pr13683"
|
run_dump_test "pr13683" $symdefs
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [check_compiler_available] } {
|
if { [check_compiler_available] } {
|
||||||
ld_compile "$CC $CFLAGS $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
|
ld_compile "$CC $CFLAGS $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
|
||||||
run_dump_test "pr14265"
|
run_dump_test "pr14265" $symdefs
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [check_compiler_available] } {
|
if { [check_compiler_available] } {
|
||||||
ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o
|
ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o
|
||||||
ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
|
ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
|
||||||
set saved_LDFLAGS "$LDFLAGS"
|
|
||||||
if [istarget hppa*-*-linux*] {
|
if [istarget hppa*-*-linux*] {
|
||||||
set LDFLAGS "$LDFLAGS --defsym '\$\$dyncall=0'"
|
set symdefs {{ld {--defsym '\$\$dyncall=0'}}}
|
||||||
}
|
}
|
||||||
run_dump_test "pr19161"
|
run_dump_test "pr19161" $symdefs
|
||||||
set LDFLAGS "$saved_LDFLAGS"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [is_elf_format] && [check_shared_lib_support] \
|
if { [is_elf_format] && [check_shared_lib_support] \
|
||||||
|
@ -185,3 +195,4 @@ if { [is_elf_format] } then {
|
||||||
}
|
}
|
||||||
|
|
||||||
set ASFLAGS $old_asflags
|
set ASFLAGS $old_asflags
|
||||||
|
set LDFLAGS $old_ldflags
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
|
|
||||||
#...
|
#...
|
||||||
0*[1-9a-f]+[0-9a-f]*[ ](T|D)[ ]_*foo
|
0*[1-9a-f]+[0-9a-f]*[ ](T|D)[ ]_*foo
|
||||||
|
#...
|
||||||
0*[1-9a-f]+[0-9a-f]*[ ](T|D)[ ]_*foo2
|
0*[1-9a-f]+[0-9a-f]*[ ](T|D)[ ]_*foo2
|
||||||
#...
|
#...
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
#nm: --format=bsd --numeric-sort
|
#nm: --format=bsd --numeric-sort
|
||||||
|
|
||||||
#...
|
#...
|
||||||
[0-9a-f]+[ ][dD][ ]_*foo1_start
|
[0-9a-f]+ ([dD] _*foo1_start|D _*foo1)
|
||||||
#...
|
#...
|
||||||
[0-9a-f]+[ ]D[ ]_*foo1
|
[0-9a-f]+ (D _*foo1|[dD] _*foo1_start)
|
||||||
#...
|
#...
|
||||||
[0-9a-f]+[ ][dD][ ]_*foo1_end
|
[0-9a-f]+ [dD] _*foo1_end
|
||||||
[0-9a-f]+[ ][dD][ ]_*foo2_start
|
#...
|
||||||
[0-9a-f]+[ ]D[ ]_*foo2
|
[0-9a-f]+ ([dD] _*foo2_start|D _*foo2)
|
||||||
[0-9a-f]+[ ][dD][ ]_*foo2_end
|
#...
|
||||||
|
[0-9a-f]+ (D _*foo2|[dD] _*foo2_start)
|
||||||
|
#...
|
||||||
|
[0-9a-f]+ [dD] _*foo2_end
|
||||||
#...
|
#...
|
||||||
|
|
|
@ -76,7 +76,11 @@ set flags [big_or_little_endian]
|
||||||
|
|
||||||
# arc-elf32 requires the symbol __SDATA_BEGIN__ to always be present.
|
# arc-elf32 requires the symbol __SDATA_BEGIN__ to always be present.
|
||||||
if [istarget arc*-*-elf32] {
|
if [istarget arc*-*-elf32] {
|
||||||
set flags "$flags --defsym=__SDATA_BEGIN__=0"
|
append flags " --defsym __SDATA_BEGIN__=0"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [is_pecoff_format] {
|
||||||
|
append flags " --image-base 0"
|
||||||
}
|
}
|
||||||
|
|
||||||
set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"]
|
set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"]
|
||||||
|
|
|
@ -238,7 +238,10 @@ proc run_srec_test { test objs } {
|
||||||
# poorly with a.out.
|
# poorly with a.out.
|
||||||
|
|
||||||
if { $sizeof_headers } {
|
if { $sizeof_headers } {
|
||||||
set flags "$flags -Ttext 0x1000"
|
append flags " -Ttext 0x1000"
|
||||||
|
if [is_pecoff_format] {
|
||||||
|
append flags " --image-base 0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ARM targets cannot convert format in the linker
|
# ARM targets cannot convert format in the linker
|
||||||
|
@ -295,12 +298,12 @@ proc run_srec_test { test objs } {
|
||||||
|
|
||||||
# Xtensa ELF targets relax by default; S-Record linker does not
|
# Xtensa ELF targets relax by default; S-Record linker does not
|
||||||
if [istarget xtensa*-*-*] {
|
if [istarget xtensa*-*-*] {
|
||||||
set flags "$flags -no-relax"
|
append flags " -no-relax"
|
||||||
}
|
}
|
||||||
|
|
||||||
# PRU ELF target relaxes by default; S-Record linker does not
|
# PRU ELF target relaxes by default; S-Record linker does not
|
||||||
if [istarget pru*-*-*] {
|
if [istarget pru*-*-*] {
|
||||||
set flags "$flags -no-relax"
|
append flags " -no-relax"
|
||||||
}
|
}
|
||||||
|
|
||||||
if { ![ld_link $ld tmpdir/sr1 "$flags $objs"] \
|
if { ![ld_link $ld tmpdir/sr1 "$flags $objs"] \
|
||||||
|
|
|
@ -380,7 +380,7 @@ proc ld_link_defsyms {} {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Windows targets need __main, some prefixed with underscore.
|
# Windows targets need __main, some prefixed with underscore.
|
||||||
if {[istarget *-*-cygwin* ] || [istarget *-*-mingw*]} {
|
if [is_pecoff_format] {
|
||||||
append flags " --defsym __main=main --defsym ___main=main"
|
append flags " --defsym __main=main --defsym ___main=main"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue