summaryrefslogtreecommitdiff
path: root/compiler/linker
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2018-02-16 16:16:39 +0000
committer David Srbecky <dsrbecky@google.com> 2018-02-16 16:53:24 +0000
commitd2645a3c867e523d62c11ee9117ef245cc5b4d1f (patch)
treed953329267c6bdffb5adf01557c8681814d528b9 /compiler/linker
parentd1652d14fbf477b3091eec3764b9890f2c072055 (diff)
Ensure local debug symbols are generated first.
This is what the spec says, and newer tools warn about it. I expect it is of little consequence otherwise. Test: Checkout output with readelf Change-Id: Icd358181f41304d3121a85f87b34e563b0e59073
Diffstat (limited to 'compiler/linker')
-rw-r--r--compiler/linker/elf_builder.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/linker/elf_builder.h b/compiler/linker/elf_builder.h
index 3145497091..f4fcf49675 100644
--- a/compiler/linker/elf_builder.h
+++ b/compiler/linker/elf_builder.h
@@ -201,7 +201,7 @@ class ElfBuilder FINAL {
return section_index_ != 0;
}
- private:
+ protected:
// Add this section to the list of generated ELF sections (if not there already).
// It also ensures the alignment is sufficient to generate valid program headers,
// since that depends on the previous section. It returns the required alignment.
@@ -345,7 +345,7 @@ class ElfBuilder FINAL {
type,
flags,
strtab,
- /* info */ 0,
+ /* info */ 1,
sizeof(Elf_Off),
sizeof(Elf_Sym)) {
syms_.push_back(Elf_Sym()); // The symbol table always has to start with NULL symbol.
@@ -386,6 +386,11 @@ class ElfBuilder FINAL {
sym.st_shndx = section_index;
sym.st_info = (binding << 4) + (type & 0xf);
syms_.push_back(sym);
+
+ // The sh_info file must be set to index one-past the last local symbol.
+ if (binding == STB_LOCAL) {
+ this->header_.sh_info = syms_.size();
+ }
}
Elf_Word GetCacheSize() { return syms_.size() * sizeof(Elf_Sym); }