aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2016-01-22 21:13:24 +0000
committerPete Cooper <peter_cooper@apple.com>2016-01-22 21:13:24 +0000
commitb6e5b42c333514a9a4b7b988daab64ced4504801 (patch)
tree4579f690b440c152897aab60cb85ec53c3d849d2 /unittests
parent0f6cf63822eb89cc8576000ffe932e32bafa0c1a (diff)
downloadlld-b6e5b42c333514a9a4b7b988daab64ced4504801.tar.gz
Add support for export_dynamic cmdline option and behaviour.
This option matches the behaviour of ld64, that is it prevents globals from being dead stripped in executables and dylibs. Reviewed by Lang Hames Differential Revision: http://reviews.llvm.org/D16026 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@258554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/DriverTests/DarwinLdDriverTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/DriverTests/DarwinLdDriverTest.cpp b/unittests/DriverTests/DarwinLdDriverTest.cpp
index e2809c449..4b3bfe84f 100644
--- a/unittests/DriverTests/DarwinLdDriverTest.cpp
+++ b/unittests/DriverTests/DarwinLdDriverTest.cpp
@@ -84,9 +84,34 @@ TEST_F(DarwinLdParserTest, DeadStripRootsExe) {
TEST_F(DarwinLdParserTest, DeadStripRootsDylib) {
EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-dylib", "-dead_strip", "foo.o",
nullptr));
+ EXPECT_FALSE(_ctx.globalsAreDeadStripRoots());
+}
+
+TEST_F(DarwinLdParserTest, DeadStripRootsRelocatable) {
+ EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-r", "-dead_strip", "foo.o",
+ nullptr));
+ EXPECT_FALSE(_ctx.globalsAreDeadStripRoots());
+}
+
+TEST_F(DarwinLdParserTest, DeadStripRootsExportDynamicExe) {
+ EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-dead_strip",
+ "-export_dynamic", "foo.o", nullptr));
EXPECT_TRUE(_ctx.globalsAreDeadStripRoots());
}
+TEST_F(DarwinLdParserTest, DeadStripRootsExportDynamicDylib) {
+ EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-dylib", "-dead_strip",
+ "-export_dynamic", "foo.o",
+ nullptr));
+ EXPECT_TRUE(_ctx.globalsAreDeadStripRoots());
+}
+
+TEST_F(DarwinLdParserTest, DeadStripRootsExportDynamicRelocatable) {
+ EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-r", "-dead_strip",
+ "-export_dynamic", "foo.o", nullptr));
+ EXPECT_FALSE(_ctx.globalsAreDeadStripRoots());
+}
+
TEST_F(DarwinLdParserTest, Arch) {
EXPECT_TRUE(parse("ld", "-arch", "x86_64", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::arch_x86_64, _ctx.arch());