Hi malware fighters,
Here is a nice test suite for weak symbols in ELF targets, everyone knows the consequences of weak cgi (old targeting method but still dangerously exploitable).
---------------------
set testname "weak symbols"
-# This test only works for ELF targets. It ought to work for some
-# a.out targets, but it doesn't.
-if ![is_elf_format] {
+# This test only works for ELF targets.
+# It ought to work for some a.out targets, but it doesn't.
+if {! [is_elf_format] && ! [is_pecoff_format]} {
+ unsupported $testname
return
}
+# Weak symbols are broken for non-i386 PE targets.
+if {! [istarget i?86-*-*]} {
+ setup_xfail *-*-pe*
+}
if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
|| ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then {
#
+# is_pecoff_format
+# true if the object format is known to be PECOFF
+#
+proc is_pecoff_format {} {
+ if { ![istarget *-*-mingw32*] \
+ && ![istarget *-*-cygwin*] \
+ && ![istarget *-*-pe*] } {
+ return 0
+ }
+
+ return 1
+}
+
+#
# simple_diff
# compares two files line-by-line
# returns differences if exist
@@ -29,15 +29,23 @@
&& ![istarget *-*-linux*] \
&& ![istarget *-*-irix5*] \
&& ![istarget *-*-irix6*] \
+ && ![is_pecoff_format] \
&& ![istarget *-*-solaris2*] } then {
+ unsupported $testname
return
}
if { [istarget *-*-linux*aout*] \
|| [istarget *-*-linux*oldld*] } {
+ unsupported $testname
return
}
+# Weak symbols are broken for non-i386 PE targets.
+if {! [istarget i?86-*-*]} {
+ setup_xfail *-*-pe*
+}
+
if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then {
# It's OK if .weak doesn't work on this target.
unresolved $testname
------------------------------------
Impliment, and enjoy,
polonus