Link .dynamic to .dynstr
This is what the ELF specification says we should do.
(see Figure 1-13: sh_link and sh_info Interpretation)
Also make the entity size of string sections 0 (i.e. not a table).
Size 1 makes some sense as well but it is not what other tools do.
Bug: 20556771
Change-Id: I780ba2e13c09c33c143fca70b38a35f3b8528fb2
diff --git a/compiler/elf_builder.h b/compiler/elf_builder.h
index 8260c68..fa69434 100644
--- a/compiler/elf_builder.h
+++ b/compiler/elf_builder.h
@@ -267,7 +267,7 @@
class StrtabSection FINAL : public Section {
public:
StrtabSection(const std::string& name, Elf_Word flags)
- : Section(name, SHT_STRTAB, flags, nullptr, 0, 1, 1) {
+ : Section(name, SHT_STRTAB, flags, nullptr, 0, 1, 0) {
buffer_.reserve(4 * KB);
// The first entry of strtab must be empty string.
buffer_ += '\0';
@@ -503,7 +503,7 @@
text_(".text", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR,
nullptr, 0, kPageSize, 0, text_size, text_writer),
bss_(".bss", bss_size),
- dynamic_(".dynamic", &dynsym_),
+ dynamic_(".dynamic", &dynstr_),
strtab_(".strtab", 0),
symtab_(".symtab", SHT_SYMTAB, 0, &strtab_),
shstrtab_(".shstrtab", 0) {