[lld] r311315 - [ELF] - Recommit "[ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions."

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 01:31:14 PDT 2017


Author: grimar
Date: Mon Aug 21 01:31:14 2017
New Revision: 311315

URL: http://llvm.org/viewvc/llvm-project?rev=311315&view=rev
Log:
[ELF] - Recommit "[ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions."

With fix: explicitly specify ouput format for hexdump tool call.

Original commit message:

[ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions.

Previously last 4 bytes of executable loads
were not filled with trap instructions,
patch fixes this bug.

Differential revision: https://reviews.llvm.org/D36262

Added:
    lld/trunk/test/ELF/fill-trap.s
      - copied, changed from r311313, lld/trunk/test/ELF/fill-trap.s
Modified:
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/ELF/build-id.s

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=311315&r1=311314&r2=311315&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Aug 21 01:31:14 2017
@@ -1856,7 +1856,7 @@ template <class ELFT> void Writer<ELFT>:
 }
 
 static void fillTrap(uint8_t *I, uint8_t *End) {
-  for (; I + 4 < End; I += 4)
+  for (; I + 4 <= End; I += 4)
     memcpy(I, &Target->TrapInstr, 4);
 }
 

Modified: lld/trunk/test/ELF/build-id.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/build-id.s?rev=311315&r1=311314&r2=311315&view=diff
==============================================================================
--- lld/trunk/test/ELF/build-id.s (original)
+++ lld/trunk/test/ELF/build-id.s Mon Aug 21 01:31:14 2017
@@ -48,15 +48,15 @@ _start:
 # DEFAULT:      Contents of section .note.test:
 # DEFAULT:      Contents of section .note.gnu.build-id:
 # DEFAULT-NEXT: 04000000 08000000 03000000 474e5500  ............GNU.
-# DEFAULT-NEXT: d618a375 bc6301ec
+# DEFAULT-NEXT: b0148597 ba5eb7e9
 
 # MD5:      Contents of section .note.gnu.build-id:
 # MD5-NEXT: 04000000 10000000 03000000 474e5500  ............GNU.
-# MD5-NEXT: 051084fe ce1f30ed e035b79e 11262808
+# MD5-NEXT: dce3bcaf 5219454c e89a1fc7 86ab17bd
 
 # SHA1:      Contents of section .note.gnu.build-id:
 # SHA1-NEXT: 04000000 14000000 03000000 474e5500  ............GNU.
-# SHA1-NEXT: c70b9aec 903fd291 8b677cd8 1e04f8b6
+# SHA1-NEXT: 2f716666 fe3668fe 370a02a1 579c3eb2
 
 # UUID:      Contents of section .note.gnu.build-id:
 # UUID-NEXT: 04000000 10000000 03000000 474e5500  ............GNU.

Copied: lld/trunk/test/ELF/fill-trap.s (from r311313, lld/trunk/test/ELF/fill-trap.s)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/fill-trap.s?p2=lld/trunk/test/ELF/fill-trap.s&p1=lld/trunk/test/ELF/fill-trap.s&r1=311313&r2=311315&rev=311315&view=diff
==============================================================================
--- lld/trunk/test/ELF/fill-trap.s (original)
+++ lld/trunk/test/ELF/fill-trap.s Mon Aug 21 01:31:14 2017
@@ -3,7 +3,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 # RUN: ld.lld %t -o %t2
 # RUN: llvm-readobj -program-headers %t2 | FileCheck %s
-# RUN: hexdump -v -s 0x0001ff0 %t2 | FileCheck %s -check-prefix=FILL
+# RUN: hexdump -v -s 0x0001ff0 -x %t2 | FileCheck %s -check-prefix=FILL
 
 # CHECK: ProgramHeader {
 # CHECK:   Type: PT_LOAD




More information about the llvm-commits mailing list