summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-04-15 17:05:10 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-04-15 17:05:10 +0000
commit80889ee82871ee418e8abfd047428a1ee65aa4b2 (patch)
treed9476cc4ceb43d6ea16130ef2d544713b8e26ff9 /utils
parent96e58e6fa27f7f86f2e89747574e849e486a20a2 (diff)
downloadrockbox-80889ee82871ee418e8abfd047428a1ee65aa4b2.tar.gz
rockbox-80889ee82871ee418e8abfd047428a1ee65aa4b2.zip
sbinfo: fix section headers generation (first section is always undefined)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29714 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/sbinfo/elf.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/utils/sbinfo/elf.c b/utils/sbinfo/elf.c
index 6c5ed2e762..f146bcc111 100644
--- a/utils/sbinfo/elf.c
+++ b/utils/sbinfo/elf.c
@@ -102,7 +102,7 @@ void elf_output(struct elf_params_t *params, elf_write_fn_t write, void *user)
102 ehdr.e_phentsize = sizeof phdr; 102 ehdr.e_phentsize = sizeof phdr;
103 ehdr.e_phnum = phnum; 103 ehdr.e_phnum = phnum;
104 ehdr.e_shentsize = sizeof shdr; 104 ehdr.e_shentsize = sizeof shdr;
105 ehdr.e_shnum = phnum + 1; 105 ehdr.e_shnum = phnum + 2; /* one for section 0 and one for string table */
106 ehdr.e_shstrndx = ehdr.e_shnum - 1; 106 ehdr.e_shstrndx = ehdr.e_shnum - 1;
107 ehdr.e_phoff = ehdr.e_ehsize; 107 ehdr.e_phoff = ehdr.e_ehsize;
108 ehdr.e_shoff = ehdr.e_ehsize + ehdr.e_phnum * ehdr.e_phentsize; 108 ehdr.e_shoff = ehdr.e_ehsize + ehdr.e_phnum * ehdr.e_phentsize;
@@ -141,6 +141,24 @@ void elf_output(struct elf_params_t *params, elf_write_fn_t write, void *user)
141 141
142 sec = params->first_section; 142 sec = params->first_section;
143 offset = ehdr.e_shoff; 143 offset = ehdr.e_shoff;
144
145 {
146 shdr.sh_name = 0;
147 shdr.sh_type = SHT_NULL;
148 shdr.sh_flags = 0;
149 shdr.sh_addr = 0;
150 shdr.sh_offset = 0;
151 shdr.sh_size = 0;
152 shdr.sh_link = SHN_UNDEF;
153 shdr.sh_info = 0;
154 shdr.sh_addralign = 0;
155 shdr.sh_entsize = 0;
156
157 write(user, offset, &shdr, sizeof shdr);
158
159 offset += sizeof(Elf32_Shdr);
160 }
161
144 while(sec) 162 while(sec)
145 { 163 {
146 shdr.sh_name = text_strtbl; 164 shdr.sh_name = text_strtbl;
@@ -165,7 +183,7 @@ void elf_output(struct elf_params_t *params, elf_write_fn_t write, void *user)
165 183
166 { 184 {
167 shdr.sh_name = bss_strtbl; 185 shdr.sh_name = bss_strtbl;
168 shdr.sh_type = SHT_STRTAB; 186 shdr.sh_type = SHT_STRTAB;
169 shdr.sh_flags = 0; 187 shdr.sh_flags = 0;
170 shdr.sh_addr = 0; 188 shdr.sh_addr = 0;
171 shdr.sh_offset = strtbl_offset + data_offset; 189 shdr.sh_offset = strtbl_offset + data_offset;