[PATCH] D37276: [yaml2obj][ELF] Make symbols optional for relocations
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 30 16:14:48 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312192: [yaml2obj][ELF] Make symbols optional for relocations (authored by phosek).
Changed prior to commit:
https://reviews.llvm.org/D37276?vs=113315&id=113332#toc
Repository:
rL LLVM
https://reviews.llvm.org/D37276
Files:
llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
llvm/trunk/test/tools/yaml2obj/invalid-symboless-relocation.yaml
llvm/trunk/test/tools/yaml2obj/symboless-relocation.yaml
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Index: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
===================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp
@@ -459,7 +459,8 @@
// Some special relocation, R_ARM_v4BX for instance, does not have
// an external reference. So it ignores the return value of lookup()
// here.
- SymN2I.lookup(Rel.Symbol, SymIdx);
+ if (Rel.Symbol)
+ SymN2I.lookup(*Rel.Symbol, SymIdx);
if (IsRela) {
Elf_Rela REntry;
Index: llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
===================================================================
--- llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
+++ llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
@@ -161,7 +161,7 @@
llvm::yaml::Hex64 Offset;
int64_t Addend;
ELF_REL Type;
- StringRef Symbol;
+ Optional<StringRef> Symbol;
};
struct RelocationSection : Section {
Index: llvm/trunk/test/tools/yaml2obj/symboless-relocation.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/symboless-relocation.yaml
+++ llvm/trunk/test/tools/yaml2obj/symboless-relocation.yaml
@@ -0,0 +1,21 @@
+# Just make sure this isn't an error even though it has no Symbol
+# RUN: yaml2obj %s
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Content: "00000000"
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ Info: .text
+ Relocations:
+ - Offset: 0x1000
+ Type: R_X86_64_RELATIVE
Index: llvm/trunk/test/tools/yaml2obj/invalid-symboless-relocation.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/invalid-symboless-relocation.yaml
+++ llvm/trunk/test/tools/yaml2obj/invalid-symboless-relocation.yaml
@@ -0,0 +1,29 @@
+# This test succeeds but produces an invalid relocation. This test
+# documents this behavoir.
+# RUN: yaml2obj %s > %t
+# RUN: llvm-readobj -relocations %t | FileCheck %s
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Content: "00000000"
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ Info: .text
+ Relocations:
+ - Offset: 0x1000
+ Type: R_X86_64_PC32
+
+#CHECK: Relocations [
+#CHECK-NEXT: Section (2) .rel.text {
+#CHECK-NEXT: 0x1000 R_X86_64_PC32 - 0x0
+#CHECK-NEXT: }
+#CHECK-NEXT:]
Index: llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
@@ -853,7 +853,7 @@
assert(Object && "The IO context is not initialized");
IO.mapRequired("Offset", Rel.Offset);
- IO.mapRequired("Symbol", Rel.Symbol);
+ IO.mapOptional("Symbol", Rel.Symbol);
if (Object->Header.Machine == ELFYAML::ELF_EM(ELF::EM_MIPS) &&
Object->Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37276.113332.patch
Type: text/x-patch
Size: 3430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170830/237610f5/attachment.bin>
More information about the llvm-commits
mailing list