aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/sortextable.h
diff options
context:
space:
mode:
authorShile Zhang <shile.zhang@linux.alibaba.com>2019-12-04 08:46:27 +0800
committerIngo Molnar <mingo@kernel.org>2019-12-13 10:47:31 +0100
commit3c47b787b6516d2c3cbaa193fe13a83adbaaad1f (patch)
treedfee893f535e2b249c88229d28a79afec7e25452 /scripts/sortextable.h
parentMerge tag 'ceph-for-5.5-rc2' of git://github.com/ceph/ceph-client (diff)
downloadlinux-dev-3c47b787b6516d2c3cbaa193fe13a83adbaaad1f.tar.xz
linux-dev-3c47b787b6516d2c3cbaa193fe13a83adbaaad1f.zip
scripts/sortextable: Rewrite error/success handling
The scripts/sortextable.c code has originally copied some code from scripts/recordmount.c, which used the same setjmp/longjmp method to manage control flow. Meanwhile recordmcount has improved its error handling via: 3f1df12019f3 ("recordmcount: Rewrite error/success handling"). So rewrite this part of sortextable as well to get rid of the setjmp/longjmp kludges, with additional refactoring, to make it more readable and easier to extend. No functional changes intended. [ mingo: Rewrote the changelog. ] Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Michal Marek <michal.lkml@markovi.net> Cc: linux-kbuild@vger.kernel.org Link: https://lkml.kernel.org/r/20191204004633.88660-2-shile.zhang@linux.alibaba.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'scripts/sortextable.h')
-rw-r--r--scripts/sortextable.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/sortextable.h b/scripts/sortextable.h
index d4b3f6c40f02..5a62e94df678 100644
--- a/scripts/sortextable.h
+++ b/scripts/sortextable.h
@@ -87,7 +87,7 @@ static int compare_extable(const void *a, const void *b)
return 0;
}
-static void
+static int
do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
{
Elf_Shdr *shdr;
@@ -146,17 +146,17 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
}
if (strtab_sec == NULL) {
fprintf(stderr, "no .strtab in file: %s\n", fname);
- fail_file();
+ return -1;
}
if (symtab_sec == NULL) {
fprintf(stderr, "no .symtab in file: %s\n", fname);
- fail_file();
+ return -1;
}
symtab = (const Elf_Sym *)((const char *)ehdr +
_r(&symtab_sec->sh_offset));
if (extab_sec == NULL) {
fprintf(stderr, "no __ex_table in file: %s\n", fname);
- fail_file();
+ return -1;
}
strtab = (const char *)ehdr + _r(&strtab_sec->sh_offset);
@@ -190,7 +190,7 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
fprintf(stderr,
"no main_extable_sort_needed symbol in file: %s\n",
fname);
- fail_file();
+ return -1;
}
sort_needed_sec = &shdr[get_secindex(r2(&sym->st_shndx),
sort_needed_sym - symtab,
@@ -206,4 +206,5 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
#endif
/* We sorted it, clear the flag. */
w(0, sort_done_location);
+ return 0;
}