[PATCH] D25609: [ELF] - Don't crash on multiple SHT_MIPS_REGINFO/SHT_MIPS_ABIFLAGS sections.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 04:41:12 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL284376: [ELF] - Don't crash on multiple SHT_MIPS_REGINFO/SHT_MIPS_ABIFLAGS sections. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D25609?vs=74662&id=74825#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25609

Files:
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/test/ELF/invalid/mips-multiple-abiflags.test
  lld/trunk/test/ELF/invalid/mips-multiple-reginfo.test


Index: lld/trunk/test/ELF/invalid/mips-multiple-reginfo.test
===================================================================
--- lld/trunk/test/ELF/invalid/mips-multiple-reginfo.test
+++ lld/trunk/test/ELF/invalid/mips-multiple-reginfo.test
@@ -0,0 +1,25 @@
+# RUN: yaml2obj %s -o %t
+# RUN: not ld.lld %t -o %tout 2>&1 | FileCheck %s
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS32
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_MIPS
+  Flags:    [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
+
+Sections:
+  - Name:          .foo1
+    Type:          SHT_MIPS_REGINFO
+    Flags:         [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:  16
+    Content:       "000000000000000000000000000000000000000000000000"
+
+  - Name:          .foo2
+    Type:          SHT_MIPS_REGINFO
+    Flags:         [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:  16
+    Content:       "000000000000000000000000000000000000000000000000"
+
+# CHECK: multiple SHT_MIPS_REGINFO sections are not allowed
Index: lld/trunk/test/ELF/invalid/mips-multiple-abiflags.test
===================================================================
--- lld/trunk/test/ELF/invalid/mips-multiple-abiflags.test
+++ lld/trunk/test/ELF/invalid/mips-multiple-abiflags.test
@@ -0,0 +1,21 @@
+# RUN: yaml2obj %s -o %t
+# RUN: not ld.lld %t -o %tout 2>&1 | FileCheck %s
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS32
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_MIPS
+  Flags:    [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
+
+Sections:
+  - Name:          .foo1
+    Type:          SHT_MIPS_ABIFLAGS
+    ISA:           MIPS64
+
+  - Name:          .foo2
+    Type:          SHT_MIPS_ABIFLAGS
+    ISA:           MIPS64
+
+# CHECK: multiple SHT_MIPS_ABIFLAGS sections are not allowed
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -321,6 +321,9 @@
     // they can be used to reason about object compatibility.
     return &InputSection<ELFT>::Discarded;
   case SHT_MIPS_REGINFO:
+    if (MipsReginfo)
+      fatal(getFilename(this) +
+            ": multiple SHT_MIPS_REGINFO sections are not allowed");
     MipsReginfo.reset(new MipsReginfoInputSection<ELFT>(this, &Sec, Name));
     return MipsReginfo.get();
   case SHT_MIPS_OPTIONS:
@@ -330,6 +333,9 @@
     MipsOptions.reset(new MipsOptionsInputSection<ELFT>(this, &Sec, Name));
     return MipsOptions.get();
   case SHT_MIPS_ABIFLAGS:
+    if (MipsAbiFlags)
+      fatal(getFilename(this) +
+            ": multiple SHT_MIPS_ABIFLAGS sections are not allowed");
     MipsAbiFlags.reset(new MipsAbiFlagsInputSection<ELFT>(this, &Sec, Name));
     return MipsAbiFlags.get();
   case SHT_RELA:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25609.74825.patch
Type: text/x-patch
Size: 2805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/550826a3/attachment.bin>


More information about the llvm-commits mailing list