diff options
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2coff.cpp')
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2coff.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/tools/yaml2obj/yaml2coff.cpp b/llvm/tools/yaml2obj/yaml2coff.cpp index 44535077e08..ca3057de177 100644 --- a/llvm/tools/yaml2obj/yaml2coff.cpp +++ b/llvm/tools/yaml2obj/yaml2coff.cpp @@ -76,14 +76,24 @@ struct COFFParser { unsigned Index = getStringIndex(Name); std::string str = utostr(Index); if (str.size() > 7) { - errs() << "String table got too large"; + errs() << "String table got too large\n"; return false; } Sec.Header.Name[0] = '/'; std::copy(str.begin(), str.end(), Sec.Header.Name + 1); } - Sec.Header.Characteristics |= (Log2_32(Sec.Alignment) + 1) << 20; + if (Sec.Alignment) { + if (Sec.Alignment > 8192) { + errs() << "Section alignment is too large\n"; + return false; + } + if (!isPowerOf2_32(Sec.Alignment)) { + errs() << "Section alignment is not a power of 2\n"; + return false; + } + Sec.Header.Characteristics |= (Log2_32(Sec.Alignment) + 1) << 20; + } } return true; } |

