[llvm] r373316 - [yaml2obj] - Allow specifying custom Link values for SHT_HASH section.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 02:54:41 PDT 2019
Author: grimar
Date: Tue Oct 1 02:54:40 2019
New Revision: 373316
URL: http://llvm.org/viewvc/llvm-project?rev=373316&view=rev
Log:
[yaml2obj] - Allow specifying custom Link values for SHT_HASH section.
This allows setting any sh_link values for SHT_HASH sections.
Differential revision: https://reviews.llvm.org/D68214
Modified:
llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml
Modified: llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp?rev=373316&r1=373315&r2=373316&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp Tue Oct 1 02:54:40 2019
@@ -821,7 +821,7 @@ void ELFState<ELFT>::writeSectionContent
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) {
Modified: llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml?rev=373316&r1=373315&r2=373316&view=diff
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml (original)
+++ llvm/trunk/test/tools/yaml2obj/elf-hash-section.yaml Tue Oct 1 02:54:40 2019
@@ -145,3 +145,35 @@ FileHeader:
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
More information about the llvm-commits
mailing list