summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-10-17 11:31:46 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-10-17 11:31:46 +0000
commit17d566daaa4c26bf32ec5fe75ebc17ef68e1d4c6 (patch)
treeb619c8b30be1ee15eb3092b9a35ccfc9a6908aa6 /lld/ELF/InputFiles.cpp
parent21cd1a6fa98923437077b008416cd34c51be042c (diff)
downloadbcm5719-llvm-17d566daaa4c26bf32ec5fe75ebc17ef68e1d4c6.tar.gz
bcm5719-llvm-17d566daaa4c26bf32ec5fe75ebc17ef68e1d4c6.zip
[ELF] - Don't crash on multiple SHT_MIPS_REGINFO/SHT_MIPS_ABIFLAGS sections.
In continue of D25555, this patch fixes possible crash when we have multiple SHT_MIPS_REGINFO or SHT_MIPS_ABIFLAGS sections. yaml2obj was used to produce such objects. Differential revision: https://reviews.llvm.org/D25609 llvm-svn: 284376
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 3aafdbb93a7..a5f9b909f11 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -321,6 +321,9 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
// 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 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
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:
OpenPOWER on IntegriCloud