summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/FileCommon.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-04-14 06:08:07 +0000
committerRui Ueyama <ruiu@google.com>2015-04-14 06:08:07 +0000
commitf3691620dafdba93dce7a2ebc13209b4681d8237 (patch)
tree20fee97fd63bb84a99ba92dead7c8829c542b4a2 /lld/lib/ReaderWriter/ELF/FileCommon.cpp
parentf505ccf451a693eb8261a3a2f5c35f12a4360ce7 (diff)
downloadbcm5719-llvm-f3691620dafdba93dce7a2ebc13209b4681d8237.tar.gz
bcm5719-llvm-f3691620dafdba93dce7a2ebc13209b4681d8237.zip
ELF: Make common strings file-scoped constants.
llvm-svn: 234861
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/FileCommon.cpp')
-rw-r--r--lld/lib/ReaderWriter/ELF/FileCommon.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lld/lib/ReaderWriter/ELF/FileCommon.cpp b/lld/lib/ReaderWriter/ELF/FileCommon.cpp
index e4a3e40282d..c23e3f6656c 100644
--- a/lld/lib/ReaderWriter/ELF/FileCommon.cpp
+++ b/lld/lib/ReaderWriter/ELF/FileCommon.cpp
@@ -15,14 +15,20 @@ using namespace llvm::ELF;
namespace lld {
namespace elf {
+static const char *elf32_expected = "ELF32 expected, but got ELF64";
+static const char *elf64_expected = "ELF64 expected, but got ELF32";
+static const char *le_expected =
+ "Little endian files are expected, but got a big endian file.";
+static const char *be_expected =
+ "Big endian files are expected, but got a little endian file.";
+
template <>
std::error_code checkCompatibility<ELF32LE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS64)
- return make_dynamic_error_code("ELF32 expected, but got ELF64");
+ return make_dynamic_error_code(elf32_expected);
if (endian == ELFDATA2MSB)
- return make_dynamic_error_code(
- "Little endian files are expected, but got a big endian file.");
+ return make_dynamic_error_code(le_expected);
return std::error_code();
}
@@ -30,10 +36,9 @@ template <>
std::error_code checkCompatibility<ELF32BE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS64)
- return make_dynamic_error_code("ELF32 expected, but got ELF64");
+ return make_dynamic_error_code(elf32_expected);
if (endian == ELFDATA2LSB)
- return make_dynamic_error_code(
- "Big endian files are expected, but got a little endian file.");
+ return make_dynamic_error_code(be_expected);
return std::error_code();
}
@@ -41,10 +46,9 @@ template <>
std::error_code checkCompatibility<ELF64LE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS32)
- return make_dynamic_error_code("ELF64 expected, but got ELF32");
+ return make_dynamic_error_code(elf64_expected);
if (endian == ELFDATA2MSB)
- return make_dynamic_error_code(
- "Little endian files are expected, but got a big endian file.");
+ return make_dynamic_error_code(le_expected);
return std::error_code();
}
@@ -52,10 +56,9 @@ template <>
std::error_code checkCompatibility<ELF64BE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS32)
- return make_dynamic_error_code("ELF64 expected, but got ELF32");
+ return make_dynamic_error_code(elf64_expected);
if (endian == ELFDATA2LSB)
- return make_dynamic_error_code(
- "Big endian files are expected, but got a little endian file.");
+ return make_dynamic_error_code(be_expected);
return std::error_code();
}
OpenPOWER on IntegriCloud