* ld-selective: New directory with new files to test
selective linking. * lib/ld-lib.exp (ld_nm): Strip leading underscore from $name.
This commit is contained in:
parent
62c0e5bc39
commit
4b329e3518
4 changed files with 92 additions and 0 deletions
12
ld/testsuite/ld-selective/1.c
Normal file
12
ld/testsuite/ld-selective/1.c
Normal file
|
@ -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 };
|
19
ld/testsuite/ld-selective/2.c
Normal file
19
ld/testsuite/ld-selective/2.c
Normal file
|
@ -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++;
|
||||
}
|
33
ld/testsuite/ld-selective/3.cc
Normal file
33
ld/testsuite/ld-selective/3.cc
Normal file
|
@ -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() { }
|
28
ld/testsuite/ld-selective/4.cc
Normal file
28
ld/testsuite/ld-selective/4.cc
Normal file
|
@ -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() { }
|
Loading…
Reference in a new issue