[PATCH] D68214: [yaml2obj] - Allow specifying custom Link values for SHT_HASH section.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 02:54:25 PDT 2019


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373316: [yaml2obj] - Allow specifying custom Link values for SHT_HASH section. (authored by grimar, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D68214?vs=222405&id=222571#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68214

Files:
  llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
  llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml


Index: llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml
+++ llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml
@@ -145,3 +145,35 @@
 Sections:
   - Name:  .hash
     Type:  SHT_HASH
+
+## Check we can set any sh_link value with use of the "Link" tag.
+
+# RUN: yaml2obj --docnum=8 %s -o %t8
+# RUN: llvm-readobj --sections %t8 | FileCheck %s --check-prefix=LINK
+
+# LINK:      Name: .hash1
+# LINK:      Link:
+# LINK-SAME: 123
+
+# LINK:      Name: .hash2
+# LINK:      Link:
+# LINK-SAME: 1
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name: .hash1
+    Type: SHT_HASH
+    Content: ""
+    Link: 123
+  - Name: .hash2
+    Type: SHT_HASH
+    Content: ""
+    Link: .hash1
+## SHT_HASH is linked to dynamic symbol table by default if it exists.
+  - Name: .dynsym
+    Type: SHT_DYNSYM
Index: llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
@@ -821,7 +821,7 @@
       CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
 
   unsigned Link = 0;
-  if (SN2I.lookup(".dynsym", Link))
+  if (Section.Link.empty() && SN2I.lookup(".dynsym", Link))
     SHeader.sh_link = Link;
 
   if (Section.Content) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68214.222571.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191001/f106a58b/attachment.bin>


More information about the llvm-commits mailing list