summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Writer.cpp18
-rw-r--r--lld/test/ELF/relro-non-contiguous-zerosize.s62
2 files changed, 1 insertions, 79 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index f4378693743..f61be873d69 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1465,22 +1465,6 @@ static uint64_t computeFlags(uint64_t Flags) {
return Flags;
}
-// Prior to finalizeContents() an OutputSection containing SyntheticSections
-// may have 0 Size, but contain SyntheticSections that haven't had their size
-// calculated yet. We must use SyntheticSection->empty() for these sections.
-static bool isOutputSectionZeroSize(const OutputSection* Sec) {
- if (Sec->Size > 0)
- return false;
- for (BaseCommand *BC : Sec->SectionCommands) {
- if (auto *ISD = dyn_cast<InputSectionDescription>(BC))
- for (InputSection *IS : ISD->Sections)
- if (SyntheticSection *SS = dyn_cast<SyntheticSection>(IS))
- if (!SS->empty())
- return false;
- }
- return true;
-}
-
// Decide which program headers to create and which sections to include in each
// one.
template <class ELFT> std::vector<PhdrEntry *> Writer<ELFT>::createPhdrs() {
@@ -1546,7 +1530,7 @@ template <class ELFT> std::vector<PhdrEntry *> Writer<ELFT>::createPhdrs() {
bool InRelroPhdr = false;
bool IsRelroFinished = false;
for (OutputSection *Sec : OutputSections) {
- if (!needsPtLoad(Sec) || isOutputSectionZeroSize(Sec))
+ if (!needsPtLoad(Sec))
continue;
if (isRelroSection(Sec)) {
InRelroPhdr = true;
diff --git a/lld/test/ELF/relro-non-contiguous-zerosize.s b/lld/test/ELF/relro-non-contiguous-zerosize.s
deleted file mode 100644
index 27ba770f2b2..00000000000
--- a/lld/test/ELF/relro-non-contiguous-zerosize.s
+++ /dev/null
@@ -1,62 +0,0 @@
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t.o
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/copy-in-shared.s -o %t2.o
-// RUN: ld.lld -shared %t.o %t2.o -o %t.so
-
-// Check that we ignore zero sized non-relro sections that are covered by the
-// range of addresses covered by the PT_GNU_RELRO header.
-// Check that we ignore zero sized relro sections that are disjoint from the
-// range of addresses covered by the PT_GNU_RELRO header.
-// REQUIRES: x86
-
-// RUN: echo "SECTIONS { \
-// RUN: .ctors : { *(.ctors) } \
-// RUN: .large1 : { *(.large1) } \
-// RUN: .dynamic : { *(.dynamic) } \
-// RUN: .zero_size : { *(.zero_size) } \
-// RUN: .jcr : { *(.jcr) } \
-// RUN: .got.plt : { *(.got.plt) } \
-// RUN: .large2 : { *(.large2) } \
-// RUN: .data.rel.ro : { *(.data.rel.ro.*) } \
-// RUN: } " > %t.script
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3.o
-// RUN: ld.lld %t3.o %t.so -o %t --script=%t.script
-// RUN: llvm-readobj -program-headers %t | FileCheck %s
-
-// CHECK: Type: PT_GNU_RELRO
-// CHECK-NEXT: Offset:
-// CHECK-NEXT: VirtualAddress:
-// CHECK-NEXT: PhysicalAddress:
-// CHECK-NEXT: FileSize:
-// CHECK-NEXT: MemSize: 4096
-
- .section .text, "ax", @progbits
- .global _start
- .global bar
- .global foo
-_start:
- callq bar
-
- // page size non-relro sections that would alter PT_GNU_RELRO header
- // MemSize if counted as part of relro.
- .section .large1, "aw", @progbits
- .space 4 * 1024
-
- .section .large2, "aw", @progbits
- .space 4 * 1024
-
- // empty relro section
- .section .ctors, "aw", @progbits
-
- // non-empty relro section
- .section .jcr, "aw", @progbits
- .quad 0
-
- // empty non-relro section
- .section .zero_size, "aw", @progbits
- .global sym
-sym:
-
- // empty relro section
- .section .data.rel.ro, "aw", @progbits
- .global sym2
-sym2:
OpenPOWER on IntegriCloud