[lld] r289046 - [ELF] - Read 16 bits for R_386_16/R_386_PC16 relocations instead of 32.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 05:50:28 PST 2016


Author: grimar
Date: Thu Dec  8 07:50:28 2016
New Revision: 289046

URL: http://llvm.org/viewvc/llvm-project?rev=289046&view=rev
Log:
[ELF] - Read 16 bits for R_386_16/R_386_PC16 relocations instead of 32.

Looks it was theoretically incorrect if the section is at the very end of the file as
reading 32 bits would pass the end of file

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=289046&r1=289045&r2=289046&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Dec  8 07:50:28 2016
@@ -439,12 +439,13 @@ uint64_t X86TargetInfo::getImplicitAdden
   default:
     return 0;
   case R_386_16:
+  case R_386_PC16:
+    return read16le(Buf);
   case R_386_32:
   case R_386_GOT32:
   case R_386_GOT32X:
   case R_386_GOTOFF:
   case R_386_GOTPC:
-  case R_386_PC16:
   case R_386_PC32:
   case R_386_PLT32:
   case R_386_TLS_LE:




More information about the llvm-commits mailing list