summaryrefslogtreecommitdiffstats
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)
ehdr.e_phentsize = sizeof phdr;
ehdr.e_phnum = phnum;
ehdr.e_shentsize = sizeof shdr;
- ehdr.e_shnum = phnum + 1;
+ ehdr.e_shnum = phnum + 2; /* one for section 0 and one for string table */
ehdr.e_shstrndx = ehdr.e_shnum - 1;
ehdr.e_phoff = ehdr.e_ehsize;
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)
sec = params->first_section;
offset = ehdr.e_shoff;
+
+ {
+ shdr.sh_name = 0;
+ shdr.sh_type = SHT_NULL;
+ shdr.sh_flags = 0;
+ shdr.sh_addr = 0;
+ shdr.sh_offset = 0;
+ shdr.sh_size = 0;
+ shdr.sh_link = SHN_UNDEF;
+ shdr.sh_info = 0;
+ shdr.sh_addralign = 0;
+ shdr.sh_entsize = 0;
+
+ write(user, offset, &shdr, sizeof shdr);
+
+ offset += sizeof(Elf32_Shdr);
+ }
+
while(sec)
{
shdr.sh_name = text_strtbl;
@@ -165,7 +183,7 @@ void elf_output(struct elf_params_t *params, elf_write_fn_t write, void *user)
{
shdr.sh_name = bss_strtbl;
- shdr.sh_type = SHT_STRTAB;
+ shdr.sh_type = SHT_STRTAB;
shdr.sh_flags = 0;
shdr.sh_addr = 0;
shdr.sh_offset = strtbl_offset + data_offset;