[PATCH] D68087: [ELF] Set SectionBase::partition in processSectionCommands

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 09:40:00 PDT 2019


MaskRay updated this revision to Diff 221973.
MaskRay marked an inline comment as done.
MaskRay added a comment.

Fix the test


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68087/new/

https://reviews.llvm.org/D68087

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/dynamic.s


Index: test/ELF/linkerscript/dynamic.s
===================================================================
--- test/ELF/linkerscript/dynamic.s
+++ 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 [
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -513,6 +513,11 @@
           s->alignment = subalign;
       }
 
+      // Set the partition field as what OutputSection::recordSection() does.
+      // Partitions cannot be used with the SECTIONS command, so this is always
+      // 1.
+      sec->partition = 1;
+
       sec->sectionIndex = i++;
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68087.221973.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190926/de87a8a8/attachment.bin>


More information about the llvm-commits mailing list