diff options
author | Timm Bäder <tbaeder@redhat.com> | 2021-02-17 09:43:44 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-03-01 17:42:29 +0100 |
commit | ec5d1a47e3b9e73a849ed40f94e9ec8017b75b72 (patch) | |
tree | 23983ca4e9a2e0c5fd6dfe0ab77c449b2b63f05b | |
parent | e95d1fbb7745b6bb945b25b6429455ace43c9ed8 (diff) | |
download | elfutils-ec5d1a47e3b9e73a849ed40f94e9ec8017b75b72.tar.gz |
unstrip: Pull adjust_reloc() into file scope
Get rid of a nested function this way.
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/unstrip.c | 28 |
2 files changed, 21 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 065fdd58..ea8250c5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2021-02-17 Timm Bäder <tbaeder@redhat.com> + * unstrip.c (adjust_relocs): Move adjust_reloc function to... + (adjust_reloc): ... here as static top-level function taking + a map array and size as extra arguments. + +2021-02-17 Timm Bäder <tbaeder@redhat.com> + * elflint.c (check_attributes): Rename and move left function... (buffer_left): ...as static toplevel function taking both an Elf_Data pointer argument and the unsigned char pointer p. diff --git a/src/unstrip.c b/src/unstrip.c index 85803295..6e874c3a 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -432,6 +432,19 @@ update_sh_size (Elf_Scn *outscn, const Elf_Data *data) update_shdr (outscn, newshdr); } +static inline void +adjust_reloc (GElf_Xword *info, + size_t map[], size_t map_size) +{ + size_t ndx = GELF_R_SYM (*info); + if (ndx != STN_UNDEF) + { + if (ndx > map_size) + error (EXIT_FAILURE, 0, "bad symbol ndx section"); + *info = GELF_R_INFO (map[ndx - 1], GELF_R_TYPE (*info)); + } +} + /* Update relocation sections using the symbol table. */ static void adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, @@ -439,17 +452,6 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, { Elf_Data *data = elf_getdata (outscn, NULL); - inline void adjust_reloc (GElf_Xword *info) - { - size_t ndx = GELF_R_SYM (*info); - if (ndx != STN_UNDEF) - { - if (ndx > map_size) - error (EXIT_FAILURE, 0, "bad symbol ndx section"); - *info = GELF_R_INFO (map[ndx - 1], GELF_R_TYPE (*info)); - } - } - switch (shdr->sh_type) { case SHT_REL: @@ -460,7 +462,7 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, { GElf_Rel rel_mem; GElf_Rel *rel = gelf_getrel (data, i, &rel_mem); - adjust_reloc (&rel->r_info); + adjust_reloc (&rel->r_info, map, map_size); ELF_CHECK (gelf_update_rel (data, i, rel), _("cannot update relocation: %s")); } @@ -474,7 +476,7 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, { GElf_Rela rela_mem; GElf_Rela *rela = gelf_getrela (data, i, &rela_mem); - adjust_reloc (&rela->r_info); + adjust_reloc (&rela->r_info, map, map_size); ELF_CHECK (gelf_update_rela (data, i, rela), _("cannot update relocation: %s")); } |