From 320a3f5341a431d3f66c4500bc9c1bb7f3c13d90 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 4 Jun 2009 14:10:01 -0400 Subject: [PATCH] foreach_symbol_pair: Lift oldsym computations from the newsym loop. Signed-off-by: Anders Kaseorg --- objmanip.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/objmanip.c b/objmanip.c index 19a3895..40fe3bd 100644 --- a/objmanip.c +++ b/objmanip.c @@ -759,6 +759,20 @@ static void foreach_symbol_pair(struct superbfd *oldsbfd, struct superbfd *newsb asymbol *oldsym = *oldsymp; if (bfd_is_const_section(oldsym->section)) continue; + + struct supersect *old_ss = + fetch_supersect(oldsbfd, oldsym->section); + if (old_ss->type == SS_TYPE_SPECIAL || + old_ss->type == SS_TYPE_EXPORT) + continue; + + struct span *old_span = find_span(old_ss, oldsym->value); + if (old_span == NULL) { + err(oldsbfd, "Could not find span for %s\n", + oldsym->name); + DIE; + } + for (newsymp = newsbfd->syms.data; newsymp < newsbfd->syms.data + newsbfd->syms.size; newsymp++) { @@ -768,25 +782,14 @@ static void foreach_symbol_pair(struct superbfd *oldsbfd, struct superbfd *newsb if (strcmp(oldsym->name, newsym->name) != 0) continue; - struct supersect *old_ss = - fetch_supersect(oldsbfd, oldsym->section); struct supersect *new_ss = fetch_supersect(newsbfd, newsym->section); - if ((old_ss->type != new_ss->type && - old_ss->type != new_ss->orig_type) || - old_ss->type == SS_TYPE_SPECIAL || - old_ss->type == SS_TYPE_EXPORT) + if (old_ss->type != new_ss->type && + old_ss->type != new_ss->orig_type) continue; - struct span *old_span = - find_span(old_ss, oldsym->value); struct span *new_span = find_span(new_ss, newsym->value); - if (old_span == NULL) { - err(oldsbfd, "Could not find span for %s\n", - oldsym->name); - DIE; - } if (new_span == NULL) { err(newsbfd, "Could not find span for %s\n", newsym->name); -- 2.11.4.GIT