[ELF] Explicitly write null bytes in string tables
authorJames Henderson <jh7370@my.bristol.ac.uk>
Fri, 4 Aug 2017 09:07:55 +0000 (09:07 +0000)
committerJames Henderson <jh7370@my.bristol.ac.uk>
Fri, 4 Aug 2017 09:07:55 +0000 (09:07 +0000)
commita5bc09a86f3bbd5836cf2a86566c459b866b2935
tree8e8e6b4f7a2c7bf4a16726b8b301def2d4c9f191
parent9c0f79663ef23b665c3834e3d6fda10176b2edfb
[ELF] Explicitly write null bytes in string tables

Following r309829, if a string table appears in an executable segment, the strings
will not be null terminated. This is a problem, for example, for the .dynstr
section when using -no-rosegment. The strings end up being terminated with 0xcc
because prior to this patch, LLD did not explicitly write the null terminators.
This change fixes that by always writing the null terminators.

Reviewers: rafael

Differential Revision: https://reviews.llvm.org/D36267

llvm-svn: 310042
lld/ELF/SyntheticSections.cpp
lld/test/ELF/dynstr-no-rosegment.s [new file with mode: 0644]