[lld] r249359 - [ELF2/AArch64] Read the right amount of bytes.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 15:43:42 PDT 2015


Author: davide
Date: Mon Oct  5 17:43:42 2015
New Revision: 249359

URL: http://llvm.org/viewvc/llvm-project?rev=249359&view=rev
Log:
[ELF2/AArch64] Read the right amount of bytes.

This was clearly wrong (thanks Rui for spotting), and I honestly would 
like to get this tested so such mistakes won't repeat. Unfortunately, I
wasn't (easily) able to craft a test that exposes the bad behavior.
Ideally, we would like to get tests of this kind for all relocations, but
at the time of writing, this is not true. So, for now just fix this bug
and try to re-evaluate a way to test this in the future.

Modified:
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=249359&r1=249358&r2=249359&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Oct  5 17:43:42 2015
@@ -286,7 +286,7 @@ static void handle_ABS16(uint8_t *Locati
   uint64_t X = S + A;
   if (!isInt<16>(X)) // -2^15 <= X < 2^16
     error("Relocation R_AARCH64_ABS16 out of range");
-  write16le(Location, read32le(Location) | X);
+  write16le(Location, read16le(Location) | X);
 }
 
 static void handle_ABS32(uint8_t *Location, uint64_t S, int64_t A) {
@@ -299,7 +299,7 @@ static void handle_ABS32(uint8_t *Locati
 static void handle_ABS64(uint8_t *Location, uint64_t S, int64_t A) {
   uint64_t X = S + A;
   // No overflow check.
-  write64le(Location, read32le(Location) | X);
+  write64le(Location, read64le(Location) | X);
 }
 
 static void handle_ADD_ABS_LO12_NC(uint8_t *Location, uint64_t S, int64_t A) {




More information about the llvm-commits mailing list