[PATCH] D41928: [ELF] Fix SysV hash tables with --no-rosegment

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 22:46:31 PST 2018


smeenai updated this revision to Diff 129394.
smeenai marked an inline comment as done.
smeenai added a comment.

Rui's comment


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41928

Files:
  ELF/SyntheticSections.cpp
  test/ELF/sysv-hash-no-rosegment.s


Index: test/ELF/sysv-hash-no-rosegment.s
===================================================================
--- /dev/null
+++ test/ELF/sysv-hash-no-rosegment.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -shared --no-rosegment -o %t %t.o
+# RUN: llvm-readobj -hash-table %t | FileCheck %s
+
+# CHECK:      HashTable {
+# CHECK-NEXT:   Num Buckets: 2
+# CHECK-NEXT:   Num Chains: 2
+# CHECK-NEXT:   Buckets: [1, 0]
+# CHECK-NEXT:   Chains: [0, 0]
+# CHECK-NEXT: }
+
+callq undef at PLT
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1836,6 +1836,11 @@
 }
 
 void HashTableSection::writeTo(uint8_t *Buf) {
+  // The output buffer is not guaranteed to be zero-cleared because we pre-
+  // fill executable sections with trap instructions. This is a precaution
+  // for that case, which happens only when -no-rosegment is given.
+  memset(Buf, 0, Size);
+
   unsigned NumSymbols = InX::DynSymTab->getNumSymbols();
 
   uint32_t *P = reinterpret_cast<uint32_t *>(Buf);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41928.129394.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180111/fc3764ca/attachment.bin>


More information about the llvm-commits mailing list