Author Topic: Test suite for weak symbols in ELF targets  (Read 3860 times)

0 Members and 1 Guest are viewing this topic.

Offline polonus

  • Avast √úberevangelist
  • Probably Bot
  • *****
  • Posts: 33895
  • malware fighter
Test suite for weak symbols in ELF targets
« on: July 31, 2006, 11:21:27 PM »
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
Cybersecurity is more of an attitude than anything else. Avast Evangelists.

Use NoScript, a limited user account and a virtual machine and be safe(r)!