summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2015-06-06 17:26:28 +0000
committerSimon Atanasyan <simon@atanasyan.com>2015-06-06 17:26:28 +0000
commitc859644f67e59182fd14519d709cd3010782ce45 (patch)
treed262b3a3e3ecf0ed70eb34d9d04feebeeb24f036 /lld/lib/ReaderWriter
parent439af8550e488f83626b0462d15ca26ef9f298b2 (diff)
downloadbcm5719-llvm-c859644f67e59182fd14519d709cd3010782ce45.tar.gz
bcm5719-llvm-c859644f67e59182fd14519d709cd3010782ce45.zip
[Mips] Check symbol alignment for some MIPS relocations.
llvm-svn: 239225
Diffstat (limited to 'lld/lib/ReaderWriter')
-rw-r--r--lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
index d09010469bd..2292172a622 100644
--- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
+++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
@@ -296,34 +296,37 @@ static int64_t relocGPRel32(uint64_t S, int64_t A, uint64_t GP) {
/// \brief R_MIPS_PC18_S3, R_MICROMIPS_PC18_S3
/// local/external: (S + A - P) >> 3 (P with cleared 3 less significant bits)
-static int32_t relocPc18(uint64_t P, uint64_t S, int64_t A) {
+static ErrorOr<int64_t> relocPc18(uint64_t P, uint64_t S, int64_t A) {
A = llvm::SignExtend32<21>(A);
- // FIXME (simon): Check that S + A has 8-byte alignment
- int32_t result = S + A - ((P | 7) ^ 7);
- return result;
+ if ((S + A) & 6)
+ return make_unaligned_range_reloc_error();
+ return S + A - ((P | 7) ^ 7);
}
/// \brief R_MIPS_PC19_S2, R_MICROMIPS_PC19_S2
/// local/external: (S + A - P) >> 2
-static int32_t relocPc19(uint64_t P, uint64_t S, int64_t A) {
+static ErrorOr<int64_t> relocPc19(uint64_t P, uint64_t S, int64_t A) {
A = llvm::SignExtend32<21>(A);
- // FIXME (simon): Check that S + A has 4-byte alignment
+ if ((S + A) & 2)
+ return make_unaligned_range_reloc_error();
return S + A - P;
}
/// \brief R_MIPS_PC21_S2, R_MICROMIPS_PC21_S2
/// local/external: (S + A - P) >> 2
-static int32_t relocPc21(uint64_t P, uint64_t S, int64_t A) {
+static ErrorOr<int64_t> relocPc21(uint64_t P, uint64_t S, int64_t A) {
A = llvm::SignExtend32<23>(A);
- // FIXME (simon): Check that S + A has 4-byte alignment
+ if ((S + A) & 2)
+ return make_unaligned_range_reloc_error();
return S + A - P;
}
/// \brief R_MIPS_PC26_S2, R_MICROMIPS_PC26_S2
/// local/external: (S + A - P) >> 2
-static int32_t relocPc26(uint64_t P, uint64_t S, int64_t A) {
+static ErrorOr<int64_t> relocPc26(uint64_t P, uint64_t S, int64_t A) {
A = llvm::SignExtend32<28>(A);
- // FIXME (simon): Check that S + A has 4-byte alignment
+ if ((S + A) & 2)
+ return make_unaligned_range_reloc_error();
return S + A - P;
}
OpenPOWER on IntegriCloud