* [COMMITTED] Simplify update_rela_data by checking rel_updated
@ 2024-05-19 13:55 Mark Wielaard
0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2024-05-19 13:55 UTC (permalink / raw)
To: debugedit; +Cc: Mark Wielaard
Now that we track whether relocations have been updated per section we
can just check the section rel_updated field in update_rela_data. This
also makes sure the relbuf is always freed.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tools/debugedit.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 1a46c13dee47..2990f962cd37 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -700,6 +700,13 @@ setup_relbuf (DSO *dso, debug_section *sec)
static void
update_rela_data (DSO *dso, struct debug_section *sec)
{
+ if (! sec->rel_updated)
+ {
+ free (sec->relbuf);
+ sec->relbuf = NULL;
+ return;
+ }
+
Elf_Data *symdata;
int relsec_ndx = sec->relsec;
Elf_Data *data = elf_getdata (dso->scn[relsec_ndx], NULL);
@@ -3172,32 +3179,27 @@ edit_dwarf2 (DSO *dso)
setup_relbuf(dso, &debug_sections[DEBUG_STR_OFFSETS]);
update_str_offsets (dso);
dirty_section (DEBUG_STR_OFFSETS);
- if (debug_sections[DEBUG_STR_OFFSETS].rel_updated)
- update_rela_data (dso, &debug_sections[DEBUG_STR_OFFSETS]);
+ update_rela_data (dso, &debug_sections[DEBUG_STR_OFFSETS]);
}
/* Update any relocations addends we might have touched. */
- if (debug_sections[DEBUG_INFO].rel_updated)
- update_rela_data (dso, &debug_sections[DEBUG_INFO]);
+ update_rela_data (dso, &debug_sections[DEBUG_INFO]);
struct debug_section *types_sec = &debug_sections[DEBUG_TYPES];
while (types_sec != NULL)
{
- if (types_sec->rel_updated)
- update_rela_data (dso, types_sec);
+ update_rela_data (dso, types_sec);
types_sec = types_sec->next;
}
struct debug_section *macro_sec = &debug_sections[DEBUG_MACRO];
while (macro_sec != NULL)
{
- if (macro_sec->rel_updated)
- update_rela_data (dso, macro_sec);
+ update_rela_data (dso, macro_sec);
macro_sec = macro_sec->next;
}
- if (debug_sections[DEBUG_LINE].rel_updated)
- update_rela_data (dso, &debug_sections[DEBUG_LINE]);
+ update_rela_data (dso, &debug_sections[DEBUG_LINE]);
return 0;
}
--
2.45.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-19 13:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19 13:55 [COMMITTED] Simplify update_rela_data by checking rel_updated Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).