aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatherine Moore <clm@redhat.com>1998-10-23 21:32:56 +0000
committerCatherine Moore <clm@redhat.com>1998-10-23 21:32:56 +0000
commit4b329e35186ad5bdd66ee0dbd24d244f4761eb60 (patch)
tree6396980d8edfb73db2c545d6a763911d2626b87e
parent62c0e5bc39b35e881b9e4ab33fe3bea3b7ac6f71 (diff)
downloadgdb-4b329e35186ad5bdd66ee0dbd24d244f4761eb60.zip
gdb-4b329e35186ad5bdd66ee0dbd24d244f4761eb60.tar.gz
gdb-4b329e35186ad5bdd66ee0dbd24d244f4761eb60.tar.bz2
* ld-selective: New directory with new files to test
selective linking. * lib/ld-lib.exp (ld_nm): Strip leading underscore from $name.
-rw-r--r--ld/testsuite/ld-selective/1.c12
-rw-r--r--ld/testsuite/ld-selective/2.c19
-rw-r--r--ld/testsuite/ld-selective/3.cc33
-rw-r--r--ld/testsuite/ld-selective/4.cc28
4 files changed, 92 insertions, 0 deletions
diff --git a/ld/testsuite/ld-selective/1.c b/ld/testsuite/ld-selective/1.c
new file mode 100644
index 0000000..1202367
--- /dev/null
+++ b/ld/testsuite/ld-selective/1.c
@@ -0,0 +1,12 @@
+/* _start should be the only thing left after GC. */
+
+void _start() __asm__("_start");
+void _start()
+{
+}
+
+void dropme1()
+{
+}
+
+int dropme2[102] = { 0 };
diff --git a/ld/testsuite/ld-selective/2.c b/ld/testsuite/ld-selective/2.c
new file mode 100644
index 0000000..7295887
--- /dev/null
+++ b/ld/testsuite/ld-selective/2.c
@@ -0,0 +1,19 @@
+/* Normally we should loose foo and keep _start and _init.
+ With -u foo, we should keep that as well. */
+
+void _start() __asm__("_start");
+void _start()
+{
+}
+
+void __attribute__((section(".init")))
+_init()
+{
+}
+
+int foo() __asm__("foo");
+int foo()
+{
+ static int x = 1;
+ return x++;
+}
diff --git a/ld/testsuite/ld-selective/3.cc b/ld/testsuite/ld-selective/3.cc
new file mode 100644
index 0000000..852bc5d
--- /dev/null
+++ b/ld/testsuite/ld-selective/3.cc
@@ -0,0 +1,33 @@
+struct A
+{
+ virtual void foo();
+ virtual void bar();
+};
+
+void A::foo() { } // keep
+void A::bar() { } // loose
+
+struct B : public A
+{
+ virtual void foo();
+};
+
+void B::foo() { } // keep
+
+void _start() __asm__("_start"); // keep
+
+A a; // keep
+B b;
+A *getme() { return &a; } // keep
+
+void _start()
+{
+ getme()->foo();
+}
+
+// In addition, keep A's virtual table.
+
+// We'll wind up keeping `b' and thus B's virtual table because
+// `a' and `b' are both referenced from the constructor function.
+
+extern "C" void __main() { }
diff --git a/ld/testsuite/ld-selective/4.cc b/ld/testsuite/ld-selective/4.cc
new file mode 100644
index 0000000..9df26ac
--- /dev/null
+++ b/ld/testsuite/ld-selective/4.cc
@@ -0,0 +1,28 @@
+struct A
+{
+ virtual void foo();
+ virtual void bar();
+};
+
+void A::foo() { } // loose
+void A::bar() { } // keep
+
+struct B : public A
+{
+ virtual void foo();
+};
+
+void B::foo() { } // loose
+
+void _start() __asm__("_start"); // keep
+
+A a; // keep
+B b;
+A *getme() { return &a; } // keep
+
+void _start()
+{
+ getme()->bar();
+}
+
+extern "C" void __main() { }