OSDN Git Service

Link .dynamic to .dynstr
authorDavid Srbecky <dsrbecky@google.com>
Fri, 29 May 2015 15:33:11 +0000 (16:33 +0100)
committerDavid Srbecky <dsrbecky@google.com>
Fri, 29 May 2015 15:59:42 +0000 (15:59 +0000)
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

compiler/elf_builder.h

index 8260c68..fa69434 100644 (file)
@@ -267,7 +267,7 @@ class ElfBuilder FINAL {
   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 @@ class ElfBuilder FINAL {
       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) {