[PATCH] D36267: [ELF] Explicitly write null bytes in string tables

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 02:08:48 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL310042: [ELF] Explicitly write null bytes in string tables (authored by jhenderson).

Changed prior to commit:
  https://reviews.llvm.org/D36267?vs=109550&id=109693#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36267

Files:
  lld/trunk/ELF/SyntheticSections.cpp
  lld/trunk/test/ELF/dynstr-no-rosegment.s


Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -990,6 +990,7 @@
 void StringTableSection::writeTo(uint8_t *Buf) {
   for (StringRef S : Strings) {
     memcpy(Buf, S.data(), S.size());
+    Buf[S.size()] = '\0';
     Buf += S.size() + 1;
   }
 }
Index: lld/trunk/test/ELF/dynstr-no-rosegment.s
===================================================================
--- lld/trunk/test/ELF/dynstr-no-rosegment.s
+++ lld/trunk/test/ELF/dynstr-no-rosegment.s
@@ -0,0 +1,12 @@
+# Verify that a .dynstr in the .text segment has null byte terminators
+
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -no-rosegment -o %t.so -shared
+# RUN: llvm-objdump %t.so -s -j .dynstr | FileCheck %s
+
+# CHECK: 00666f6f 00 .foo.
+
+.globl foo
+foo:
+    ret


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36267.109693.patch
Type: text/x-patch
Size: 950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170804/aec795d8/attachment.bin>


More information about the llvm-commits mailing list