summaryrefslogtreecommitdiffstats
path: root/src/strip.c
diff options
context:
space:
mode:
authorTimm Bäder <[email protected]>2021-01-08 09:04:46 +0100
committerMark Wielaard <[email protected]>2021-01-28 13:14:13 +0100
commitb076d4c219550ea30da89fc8f5839a139ac5353d (patch)
tree93b2cdaaed1706d90cfd5cc8e4762c93ef1e009d /src/strip.c
parent7024796b63fff42274adb85cd36dbec2c55480c6 (diff)
strip: Replace nested check_preserved function with loop
Signed-off-by: Timm Bäder <[email protected]>
Diffstat (limited to 'src/strip.c')
-rw-r--r--src/strip.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/strip.c b/src/strip.c
index 7ce14ab8..c971b6c2 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -1535,25 +1535,30 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
files by setting the .debug_data pointer to the original
file's .data pointer. Below, we'll copy the section
contents. */
+ size_t shdr_indices[2] = { shdr_info[cnt].shdr.sh_link, 0 };
+ int n = 1;
- inline void check_preserved (size_t i)
- {
- if (i != 0 && i < shnum + 2 && shdr_info[i].idx != 0
- && shdr_info[i].debug_data == NULL)
- {
- if (shdr_info[i].data == NULL)
- shdr_info[i].data = elf_getdata (shdr_info[i].scn, NULL);
- if (shdr_info[i].data == NULL)
- INTERNAL_ERROR (fname);
+ if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
+ {
+ shdr_indices[1] = shdr_info[cnt].shdr.sh_info;
+ n++;
+ }
- shdr_info[i].debug_data = shdr_info[i].data;
- changes |= i < cnt;
- }
- }
+ for (int j = 0; j < n; j++)
+ {
+ size_t i = shdr_indices[j];
+ if (i != 0 && i < shnum + 2 && shdr_info[i].idx != 0
+ && shdr_info[i].debug_data == NULL)
+ {
+ if (shdr_info[i].data == NULL)
+ shdr_info[i].data = elf_getdata (shdr_info[i].scn, NULL);
+ if (shdr_info[i].data == NULL)
+ INTERNAL_ERROR (fname);
- check_preserved (shdr_info[cnt].shdr.sh_link);
- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
- check_preserved (shdr_info[cnt].shdr.sh_info);
+ shdr_info[i].debug_data = shdr_info[i].data;
+ changes |= i < cnt;
+ }
+ }
}
}
}