summaryrefslogtreecommitdiff
path: root/devel/llvm70/files/lld/patch-head-r339304.diff
blob: 8263f44801db7805554f4b9af84654e4ed42e2e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
r339304 | emaste | 2018-10-11 15:19:17 +0200 (Thu, 11 Oct 2018) | 13 lines

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies."  ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by:	re (kib)
Obtained from:	llvm r344226 (backported for 6.0)

Index: tools/lld/ELF/SyntheticSections.cpp
===================================================================
--- tools/lld/ELF/SyntheticSections.cpp	(revision 339303)
+++ tools/lld/ELF/SyntheticSections.cpp	(revision 339304)
@@ -1213,11 +1213,13 @@ void RelocationBaseSection::addReloc(const Dynamic
 void RelocationBaseSection::finalizeContents() {
   // If all relocations are R_*_RELATIVE they don't refer to any
   // dynamic symbol and we don't need a dynamic symbol table. If that
-  // is the case, just use 0 as the link.
-  Link = InX::DynSymTab ? InX::DynSymTab->getParent()->SectionIndex : 0;
+  // is the case, just use the index of the regular symbol table section.
+  getParent()->Link = InX::DynSymTab ?
+    InX::DynSymTab->getParent()->SectionIndex :
+    InX::SymTab->getParent()->SectionIndex;
 
-  // Set required output section properties.
-  getParent()->Link = Link;
+  if (InX::RelaIplt == this || InX::RelaPlt == this)
+    getParent()->Info = InX::GotPlt->getParent()->SectionIndex;
 }
 
 RelrBaseSection::RelrBaseSection()