diff options
| author | Roland McGrath <[email protected]> | 2010-06-04 02:29:08 -0700 |
|---|---|---|
| committer | Roland McGrath <[email protected]> | 2010-06-14 12:52:09 -0700 |
| commit | aa32f9237f6ce0c25cbe53291467c305b6481abb (patch) | |
| tree | 90ffadd4d9f48dea4f5b701c06c32941c8893aba | |
| parent | 3b1b651d89d14b948a7e2436efdbe89d9bf691c0 (diff) | |
unstrip: Factor common code for shdr changes.
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/unstrip.c | 29 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 90c78cb5..ab33cbf2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2010-06-04 Roland McGrath <[email protected]> + * unstrip.c (update_shdr): New function. + (update_sh_size): Call it instead of gelf_update_shdr. + (adjust_relocs, add_new_section_symbols): Likewise. + (new_shstrtab, copy_elided_sections): Likewise. + * unstrip.c (copy_elided_sections): Bail if stripped file has more sections than unstripped file, rather than getting confused later. diff --git a/src/unstrip.c b/src/unstrip.c index 755c42a3..59d3ead5 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -368,6 +368,13 @@ symtab_count_leading_section_symbols (Elf *elf, Elf_Scn *scn, size_t shnum, return shnum; } +static void +update_shdr (Elf_Scn *outscn, GElf_Shdr *newshdr) +{ + ELF_CHECK (gelf_update_shdr (outscn, newshdr), + _("cannot update section header: %s")); +} + /* We expanded the output section, so update its header. */ static void update_sh_size (Elf_Scn *outscn, const Elf_Data *data) @@ -378,8 +385,7 @@ update_sh_size (Elf_Scn *outscn, const Elf_Data *data) newshdr->sh_size = data->d_size; - ELF_CHECK (gelf_update_shdr (outscn, newshdr), - _("cannot update section header: %s")); + update_shdr (outscn, newshdr); } /* Update relocation sections using the symbol table. */ @@ -428,8 +434,7 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, if (newshdr->sh_info != STN_UNDEF) { newshdr->sh_info = map[newshdr->sh_info - 1]; - ELF_CHECK (gelf_update_shdr (outscn, newshdr), - _("cannot update section header: %s")); + update_shdr (outscn, newshdr); } break; } @@ -557,9 +562,7 @@ add_new_section_symbols (Elf_Scn *old_symscn, size_t old_shnum, shdr->sh_info += added; shdr->sh_size += added * shdr->sh_entsize; - - ELF_CHECK (gelf_update_shdr (symscn, shdr), - _("cannot update section header: %s")); + update_shdr (symscn, shdr); Elf_Data *symdata = elf_getdata (symscn, NULL); Elf_Data *shndxdata = NULL; /* XXX */ @@ -1205,8 +1208,7 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum, shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]); if (i + 1 == unstripped_shstrndx) shdr->sh_size = strtab_data->d_size; - ELF_CHECK (gelf_update_shdr (scn, shdr), - _("cannot update section header: %s")); + update_shdr (scn, shdr); } return strtab_data; @@ -1525,8 +1527,7 @@ more sections in stripped file than debug file -- arguments reversed?")); offset = end_offset; } - ELF_CHECK (gelf_update_shdr (sec->outscn, &shdr_mem), - _("cannot update section header: %s")); + update_shdr (sec->outscn, &shdr_mem); if (shdr_mem.sh_type == SHT_SYMTAB || shdr_mem.sh_type == SHT_DYNSYM) { @@ -1720,8 +1721,7 @@ more sections in stripped file than debug file -- arguments reversed?")); } elf_flagdata (symdata, ELF_C_SET, ELF_F_DIRTY); - ELF_CHECK (gelf_update_shdr (unstripped_symtab, shdr), - _("cannot update section header: %s")); + update_shdr (unstripped_symtab, shdr); if (stripped_symtab != NULL) { @@ -1791,8 +1791,7 @@ more sections in stripped file than debug file -- arguments reversed?")); if (shdr->sh_type != SHT_NOBITS) offset += shdr->sh_size; - ELF_CHECK (gelf_update_shdr (scn, shdr), - _("cannot update section header: %s")); + update_shdr (scn, shdr); if (unstripped_shstrndx == 1 + i) { |
