# Expect script for various ELF tests.
-# Copyright (C) 2002-2022 Free Software Foundation, Inc.
+# Copyright (C) 2002-2023 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
}
proc target_defaults_to_execstack {} {
+ global base_dir
+
+ # If the linker has been configured with --enable-default-execstack=no then
+ # this proc should always return 0.
+ if { [file exists $base_dir/config.status] } {
+ set status [remote_exec host grep "enable-default-execstack=no" $base_dir/config.status]
+ if { [lindex $status 0] == 0 } {
+ return 0
+ } else {
+ verbose -log "$base_dir/config.status does not contain enable-default-execstack=no"
+ }
+ } else {
+ verbose -log "there is no file $base_dir/config.status"
+ }
+
if { [istarget "aarch64*-*-*"]
|| [istarget "arc*-*-*"]
|| [istarget "cris*-*-*"]
|| [istarget "ia64*-*-*"]
+ || [istarget "loongarch*-*-*"]
|| [istarget "nios2*-*-*"]
|| [istarget "powerpc64*-*-*"]
+ || [istarget "pru*-*-*"]
|| [istarget "riscv*-*-*"]
|| [istarget "tilegx*-*-*"]
|| [istarget "tilepro*-*-*"] } {
return $text
}
- # The HPPA target disables the warnings by default since it needs an
- # executable stack to support older kernels and an RWX segment to
- # support its PLT. MIPS also turns off exec stack warnings.
- if { [istarget "hppa*-*-*"] || [istarget mips*-*-*] } {
- set extra_link_opts "--warn-execstack --warn-rwx-segments"
- } else {
- set extra_link_opts ""
+ set curr_ldflags $LDFLAGS
+ if { [istarget powerpc*-*-*] && ![istarget powerpc64*-*-*] } {
+ # Don't generate an executable .plt section
+ set LDFLAGS "$LDFLAGS --secure-plt"
}
+ # Since the warnings can be disabled by configure, ensure consistency
+ # of the first test by forcing the flags.
run_ld_link_tests [list \
[list "PR ld/29072 (warn about an executable .note.GNU-stack)" \
- "-e 0 $extra_link_opts" \
+ "-e 0 --warn-execstack --warn-rwx-segments" \
"" \
"" \
{pr29072-a.s} \
"rwx-segments-3.exe"] \
]
+ set LDFLAGS $curr_ldflags
+
if { [target_defaults_to_execstack] } {
run_ld_link_tests [list \
[list "PR ld/29072 (warn about absent .note.GNU-stack)" \
{{nm "" pr26391.nd}} \
"pr26391-4" \
] \
-]
-
-run_ld_link_tests [list \
[list \
"Build pr26391-5.o" \
- "-z unique-symbol -r" \
- "" \
- "" \
+ "-Wl,-z,unique-symbol -r -nostdlib -nostartfiles" \
+ "-fno-function-sections" \
{pr26391a.c pr26391b.c pr26391c.c pr26391d.c} \
[list \
[list "nm" "$dep_plug_opt" "pr26391.nd"] \
[list "nm" "$dep_plug_opt" "pr26391.fd"] \
] \
"pr26391-5.o" \
- "-fno-function-sections" \
] \
[list \
"Build pr26391-6.o" \
- "-z unique-symbol -r" \
- "" \
- "" \
+ "-Wl,-z,unique-symbol -r -nostdlib -nostartfiles" \
+ "-ffunction-sections" \
{pr26391a.c pr26391b.c pr26391c.c pr26391d.c} \
{{nm "" pr26391.nd}} \
"pr26391-6.o" \
- "-ffunction-sections" \
] \
]
] \
]
+set merge_exec_tests {
+ {"merge4" "" ""
+ {merge4a.c merge4b.s} "merge4" "merge4.out"}
+}
+run_ld_link_exec_tests $merge_exec_tests
+
catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status