[lld] r372996 - [ELF] Set SectionBase::partition in processSectionCommands
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 10:10:09 PDT 2019
Author: maskray
Date: Thu Sep 26 10:10:09 2019
New Revision: 372996
URL: http://llvm.org/viewvc/llvm-project?rev=372996&view=rev
Log:
[ELF] Set SectionBase::partition in processSectionCommands
Fixes PR43461 (regression caused by D67504)
The partition field of a SECTIONS-specified section is not set after
D67504. The 0 value affects findSection() which checks if the partition
field is 1.
So `Out::initArray = findSection(".init_array")` is null, and
DT_INIT_ARRAYSZ is not set.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D68087
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/dynamic.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=372996&r1=372995&r2=372996&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Sep 26 10:10:09 2019
@@ -513,6 +513,11 @@ void LinkerScript::processSectionCommand
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++;
}
}
Modified: lld/trunk/test/ELF/linkerscript/dynamic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/dynamic.s?rev=372996&r1=372995&r2=372996&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/dynamic.s (original)
+++ lld/trunk/test/ELF/linkerscript/dynamic.s Thu Sep 26 10:10:09 2019
@@ -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 [
More information about the llvm-commits
mailing list