Many of the ld tests are not run for cross builds, in some cases
because the test needs to run a newly linked executable, and in others
simply because it was easier to write the test for native only. Even
when a test needs to run, it's good to compile and link to exercise
the linker. So that's what this patch does. I've also rid us of
the old ld_link procedure with all the HOSTING_CRT0 etc. setup. It's
much simpler to just link with $CC.
This does mean that a cross build with cross-compiler installed but
no cross C-library will give lots of failures. If that turns out to
be too annoying, I guess we can write a tcl procedure to detect it and
not run all the extra tests.
* Makefile.am (bootstrap): Delete rule.
(ld-partial, ld1, ld1-full, ld2, ld3): Likewise.
(HOSTING_CRT0, HOSTING_SCRT0): Don't define.
(HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise.
* configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
(HOSTING_LIBS, HOSTING_SLIBS): Likewise.
* configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define.
* Makefile.in: Regenerate.
* configure: Regenerate.
* testsuite/config/default.exp (get_link_files): Delete.
(HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't
define.
(ld_simple_link): Delete.
* testsuite/lib/ld-lib.exp (default_ld_link): Delete
(default_ld_simple_link): Rename to default_ld_link.
(ld_simple_link_defsyms): Rename to ld_link_defsyms.
(run_ld_link_tests): Use ld_link, not ld_simple_link.
(run_cc_link_tests): Likewise.
(run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld.
Don't run exe when not native, and return unsupported.
* testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs.
Link ld1 etc. using $CC.
* testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC.
* testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link.
* testsuite/ld-cygwin/exe-export.exp: Likewise.
* testsuite/ld-elf/binutils.exp: Likewise.
* testsuite/ld-elf/eh-group.exp: Likewise.
* testsuite/ld-elf/exclude.exp: Likewise.
* testsuite/ld-elf/frame.exp: Likewise.
* testsuite/ld-elf/sec-to-seg.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
* testsuite/ld-fastcall/fastcall.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-ifunc/binutils.exp: Likewise.
* testsuite/ld-mep/mep.exp: Likewise.
* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
* testsuite/ld-mn10300/mn10300.exp: Likewise.
* testsuite/ld-nios2/nios2.exp: Likewise.
* testsuite/ld-pe/pe-compile.exp: Likewise.
* testsuite/ld-pe/pe-run.exp: Likewise.
* testsuite/ld-pe/pe-run2.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-scripts/align.exp: Likewise.
* testsuite/ld-scripts/alignof.exp: Likewise.
* testsuite/ld-scripts/assert.exp: Likewise.
* testsuite/ld-scripts/defined.exp: Likewise.
* testsuite/ld-scripts/extern.exp: Likewise.
* testsuite/ld-scripts/log2.exp: Likewise.
* testsuite/ld-scripts/map-address.exp: Likewise.
* testsuite/ld-scripts/phdrs.exp: Likewise.
* testsuite/ld-scripts/phdrs2.exp: Likewise.
* testsuite/ld-scripts/script.exp: Likewise.
* testsuite/ld-scripts/section-flags.exp: Likewise.
* testsuite/ld-scripts/sizeof.exp: Likewise.
* testsuite/ld-scripts/sysroot-prefix.exp: Likewise.
* testsuite/ld-scripts/weak.exp: Likewise.
* testsuite/ld-selective/selective.exp: Likewise.
* testsuite/ld-sh/sh.exp: Likewise.
* testsuite/ld-sh/sh64/relax.exp: Likewise.
* testsuite/ld-sh/sh64/relfail.exp: Likewise.
* testsuite/ld-srec/srec.exp: Likewise.
* testsuite/ld-tic6x/tic6x.exp: Likewise.
* testsuite/ld-undefined/weak-undef.exp: Likewise.
* testsuite/ld-versados/versados.exp: Likewise.
* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
* testsuite/ld-xtensa/coalesce.exp: Likewise.
* testsuite/ld-xtensa/diff_overflow.exp: Likewise.
* testsuite/ld-xtensa/lcall.exp: Likewise.
* testsuite/ld-elf/audit.exp: Run non-native too.
* testsuite/ld-elf/compress.exp: Likewise. Replace ld options with
gcc -Wl, options.
* testsuite/ld-elf/dwarf.exp: Run non-native too. Use ld_link,
not ld_simple_link. Add -Wl,--no-as-needed to some tests.
* testsuite/ld-elf/elf.exp: Run non-native too. Formatting.
* testsuite/ld-elf/indirect.exp: Run non-native too. Add
-Wl,--no-as-needed to most tests.
* testsuite/ld-elf/shared.exp: Run non-native too. Use braces
to simplify quoting. Set run_tests using [list] rather than
brace assignment to expand $extralibs. Add -Wl,--no-as-needed
to many test. Prefix ld options with -Wl,.
(mix_pic_and_non_pic): Don't run exe if not native.
* testsuite/ld-elf/wrap.exp: Run non-native too. Add
-Wl,--no-as-needed and prefix ld options with -Wl,.
* testsuite/ld-elfvers/vers.exp: Run non-native too. Use ld_link,
not ld_simple_link.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
(visibility_test): Don't run exe if not native.
* testsuite/ld-elfweak/elfweak.exp: Run non-native too. Use ld_link,
not ld_simple_link.
(build_exec): Don't run exe if not native.
* testsuite/ld-ifunc/ifunc.exp: Run non-native too. Use ld_link,
not ld_simple_link. Link using $CC. Add -Wl,--no-as-needed
to some tests and prefix ld options with -Wl,. Expect GNU
for hppa-linux even when no ifuncs. Delete cleanup.
* testsuite/ld-pie/pie.exp: Run non-native too.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise. Use ld_link,
not ld_simple_link.
(shared_test): Don't run exe if not native.
* testsuite/ld-size/size.exp: Run non-native too. Add
-Wl,--no-as-needed to some tests. Prefix ld options with -Wl,.
* testsuite/ld-unique/unique.exp: Run non-native too. Use ld_link,
not ld_simple_link. Link using $CC. Add -Wl,--no-as-needed
to some tests and prefix ld options with -Wl,. Expect GNU
for hppa-linux even when no unique syms. Delete cleanup.
* testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some
tests and prefix ld options with -Wl,.
* testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link.
Add -Wl,--no-as-needed to some tests. Prefix ld options with -Wl,.
Add a configure option --enable-relro to decide whether -z relro should
be enabled in ELF linker by default. Default to yes for all Linux
targets, except FRV, HPPA, IA64 and MIPS, since many relro tests fail
on these targets.
PR ld/20283
* NEWS: Mention --enable-relro.
* configure.ac: Add --enable-relro.
(DEFAULT_LD_Z_RELRO): New. Set by --enable-relro.
* configure.tgt (ac_default_ld_z_relro): Default it to 1 for
some Linux targets.
* config.in: Regenerated.
* configure: Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
link_info.relro to DEFAULT_LD_Z_RELRO.
* testsuite/config/default.exp (ld_elf_shared_opt): New.
* testsuite/lib/ld-lib.exp (run_dump_test): Pass
$ld_elf_shared_opt to ld for ELF targets with shared object
support.
(run_ld_link_tests): Likewise.
There is no need to download source if we aren't on remote host.
Otherwise, each ld test run on local host leaves behind a couple
test files.
* config/default.exp (NOPIE_CFLAGS): Download source only on
remote host.
(NOPIE_LDFLAGS): Likewise.
* testsuite/lib/ld-lib.exp (check_lto_available): Likewise.
(check_lto_fat_available): Likewise.
(check_lto_shared_available): Likewise.
(check_ifunc_available): Likewise.
(check_ifunc_attribute_available): Likewise.
Run the test for more than just ELF. Shows that objcopy --extract-symbol
isn't working on PE, mips, mmix and some aout targets.
* config/default.exp (size): New global.
* ld-elf/extract-symbol-1.s,
* ld-elf/extract-symbol-1.ld,
* ld-elf/extract-symbol-1sec.d,
* ld-elf/extract-symbol-1sym.d: Delete.
* ld-scripts/script.exp (extract_symbol_test): New.
GCC 6 can be configured to generate PIE by default. But some linker
size tests expect non-PIE. This patch defines NOPIE_CFLAGS to
"-fno-PIE" and NOPIE_LDFLAGS to "-no-pie" if target compiler supports
them. Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS to linker size tests if
needed.
* config/default.exp (NOPIE_CFLAGS): New.
(NOPIE_LDFLAGS): Likewise.
* ld-size/size.exp (run_cc_link_tests): Add $NOPIE_CFLAGS and
$NOPIE_LDFLAGS if needed.
(run_ld_link_exec_tests): Add $NOPIE_CFLAGS if needed.
GCC 6 supports -fno-plt. But some linker tests expect PLT. This patch
defines PLT_CFLAGS to "-fplt" if target compiler supports it.
* config/default.exp (PLT_CFLAGS): New.
Various ld-elf/shared.exp and ld-plugin/lto.exp tests simply appended
the testsuite -B options intended to force gcc use the linker under test.
This fails if $CC itself has -B options, as when setting CC to run gcc
out of a build directory. Net result is that tests were run using
the gcc build dir collect-ld.
* config/default.exp: Don't make tmpdir/gas. Put as symlink into
tmpdir/ld.
(gcc_gas_flag, gcc_ld_flag): Delete.
(gcc_B_opt, ld_L_opt): New globals.
ld-elf/shared.exp: Remove all refs to gcc_gas_flag and gcc_ld_flag.
ld-plugin/lto.exp: Likewise.
lib/ld-lib.exp (run_host_cmd): Add gcc_B_opt and ld_L_opt here.
(ld_simple_link): Remove -B handling now that this is done in
run_host_cmd. Simplify.
(default_ld_compile): Simplify.
(check_lto_available): Use run_host_cmd_yesno.
(check_lto_shared_available): Likewise.
default_ld_assemble.
(ld_assemble_flags): New function.
* ld-elf/frame.exp: Pass -mpic and -mpid flags to the assembler on
tic6x.
* ld-elf/exclude.exp: Likewise.
* lib/ld-lib.exp (default_ld_assemble): Take extra argument in_flags
and pass it to the assembler.
* configure.host (HOSTING_LIBS): Two dollars on shell variable
expansion to suit make.
ld/testsuite
* config/default.exp (get_link_files): Replace double dollars with
single dollars.
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma,
then on type.
binutils/testsuite:
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* binutils-all/ar.exp (long_filenames): Delete temporary files on
the host.
* binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if
host is local.
* binutils-all/objcopy.exp: Use ${srecfile} to get the name of the
srec file to be passed to binutils_run.
(objcopy_test_readelf): Use remote_exec.
* binutils-all/readelf.exp (readelf_find_size): Use remote_exec.
(readelf_test): Likewise.
(readelf_wi_test): Likewise.
* lib/utils-lib.exp (run_dump_test): Only check "which $binary" if
host is local. Use remote_exec. Use $tempfile not
tmpdir/bintest.o.
gas:
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* as.c (main): Flush stderr before printing listings to ensure
consistent output order across platforms.
gas/testsuite:
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* lib/gas-defs.exp (gas_version): Use remote_* functions instead
of exec.
(gas_host_run): New.
(gas_run): Use gas_host_run.
(gas_start): Likewise.
(run_dump_test): Likewise.
(objdump): Use gas_host_run.
(objdump_start_no_subdir): Likewise.
* lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete".
* lib/run: Remove.
* gas/macros/macros.exp: Download app4b.s to host.
* gas/i386/i386.exp (gas_64_check): Use gas_host_run.
(gas_32_check): Likewise.
* gas/maxq10/maxq10.exp (gas_64_check): Likewise
(gas_32_check): Likewise.
* gas/maxq20/maxq20.exp (gas_64_check): Likewise
(gas_32_check): Likewise.
* gas/sparc/sparc.exp (gas_64_check): Likewise.
* gas/cfi/cfi.exp: Likewise.
* gas/elf/elf.exp (run_list_test): Likewise. Use temporary file
for readelf output in place of pipe.
* gas/all/gas.exp: Download incbin.dat to host.
(do_comment): Allow \r\r\n.
ld:
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* ldlang.c (sort_sections_by_lma): Sort by internal id after lma
for stable sort.
ld/testsuite:
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which
$CC" if host is local.
* ld-checks/checks.exp: Use run_host_cmd.
* ld-elf/exclude.exp: Likewise.
* ld-elf/elf.exp: Download merge.ld if host is remote.
* ld-elf/binutils.exp (binutils_test): Use remote_exec.
* ld-elf/tls_common.exp: Use run_host_cmd.
* lib/ld-lib.exp (ld_version): Only check "which $ld" if host is
local. Use remote_exec.
(run_host_cmd): New.
(run_host_cmd_yesno): New.
(default_ld_relocate): Use run_host_cmd_yesno.
(default_ld_link): Likewise.
(default_ld_simple_link): Use run_host_cmd.
(default_ld_compile): Only check "which $ccprog" if host is local.
Use remote_file and remote_exec.
(default_ld_assemble): Only check "which $as" if host is local.
Use run_host_cmd.
(default_ld_nm): Use remote_exec, remote_upload and remote_file.
(run_dump_test): Use remote_exec, remote_upload and remote_file.
Only check "which $binary" if host is local.
(run_ld_link_tests): Use remote_exec, remote_upload and
remote_file.
* ld-selective/selective.exp: Only check "which $CXX" if host is
local. Use remote_exec.
* ld-scripts/phdrs.exp: Only check "which $objdump" if host is
local. Use run_host_cmd.
* ld-scripts/phdrs2.exp: Likewise.
* ld-scripts/weak.exp: Likewise.
* ld-undefined/weak-undef.exp: Likewise.
* ld-scripts/crossref.exp: Only check "which $CC" if host is local.
Use run_host_cmd.
* ld-scripts/map-address.exp: Upload map_address.map if host is
remote.
* ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check
"which $CC" and "which $CXX" if host is local.
* ld-undefined/undefined.exp: Only check "which $CC" if host is
local. Use remote_file and run_host_cmd.
* config/default.exp: Use remote_exec to create tmpdir.
* config/default.exp (gcc_ld_flag): New. Make the newly built
linker available to gcc.
* lib/ld-lib.exp (default_ld_simple_link): Pass $gcc_ld_flag
to gcc.
* ld-elfvers/vers.exp: Use "ld_simple_link $CC" to build shared
libraries.
* ld-elfvsb/elfvsb.exp: Likewise.
* ld-elfweak/elfweak.exp: Likewise.
* ld-shared/shared.exp: Likewise.
* ld-elfvers/vers.exp: Use "-Wl,-rpath,." to build shared
libraries.
* ld-elfvsb/elfvsb.exp: Likewise.
* ld-elfvsb/elfvsb.exp: Remove xfail for powerpc-*-linux*.
* ld-elfweak/elfweak.exp: Use PIC for shared libraries.
mips64-linux.
* ld-elf/merge.d: Xfail on mips64*-linux-gnu*.
* ld-mips-elf/mips-elf-flags.exp (ldemul): Set to o32-compatible
on mips-sgi-irix6*, mips64-linux-gnu and mips64el-linux-gnu.
(good_combination, bad_combination): Use it.
Add -32 or -mabi=o64 wherever the ABI was formerly implied.
OBJCOPYFLAGS, READELF, READELFFLAGS, LD, LDFLAGS): Provide
default.
* lib/ld-lib.exp (run_dump_test): Import from gas testsuite. Add
new options "ld", "source", "xfail", "target", "notarget" and
"error". Support the runtest_file_p "*.exp=testname" feature.
(slurp_options, regexp_diff, file_contents, verbose_eval): Import
from gas testsuite.