summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/LinkerScript.cpp5
-rw-r--r--lld/test/ELF/linkerscript/dynamic.s10
2 files changed, 12 insertions, 3 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 74fae363fe4..533f2f6ad73 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -513,6 +513,11 @@ void LinkerScript::processSectionCommands() {
s->alignment = subalign;
}
+ // Set the partition field the same way OutputSection::recordSection()
+ // does. Partitions cannot be used with the SECTIONS command, so this is
+ // always 1.
+ sec->partition = 1;
+
sec->sectionIndex = i++;
}
}
diff --git a/lld/test/ELF/linkerscript/dynamic.s b/lld/test/ELF/linkerscript/dynamic.s
index d236fba77b0..c69e752f9ad 100644
--- a/lld/test/ELF/linkerscript/dynamic.s
+++ b/lld/test/ELF/linkerscript/dynamic.s
@@ -1,10 +1,14 @@
# REQUIRES: x86
+
+## Test that DT_INIT_ARRAYSZ/DT_FINI_ARRAYSZ/DT_PREINIT_ARRAYSZ are computed
+## correctly, no matter their associated sections are orphans or not.
+
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
-# RUN: ld.lld -shared %t2.o -o %t2.so
+# RUN: ld.lld -shared %t2.o -soname=so -o %t2.so
-# RUN: echo "SECTIONS { }" > %t.script
-# RUN: ld.lld %t1.o %t2.so -o %t
+# RUN: echo "SECTIONS { .init_array : { *(.init_array) } }" > %t.script
+# RUN: ld.lld -T %t.script %t1.o %t2.so -o %t
# RUN: llvm-readobj --dynamic-table %t | FileCheck %s
# CHECK: DynamicSection [
OpenPOWER on IntegriCloud