[ELF] Don't emit .relr.dyn section if there are no relocs

This resolves PR38875.

Differential Revision: https://reviews.llvm.org/D51834

llvm-svn: 341870
This commit is contained in:
Petr Hosek 2018-09-10 21:54:56 +00:00
parent c587164422
commit c6a233a68a
2 changed files with 12 additions and 0 deletions

View File

@ -536,6 +536,7 @@ struct RelativeReloc {
class RelrBaseSection : public SyntheticSection {
public:
RelrBaseSection();
bool empty() const override { return Relocs.empty(); }
std::vector<RelativeReloc> Relocs;
};

View File

@ -0,0 +1,11 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
// RUN: ld.lld -pie --pack-dyn-relocs=relr %t.o -o %t
// RUN: llvm-readobj -sections %t | FileCheck %s
.global _start
_start:
nop
# CHECK-NOT: Name: .relr.dyn