builtin-orc.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
  4. */
  5. /*
  6. * objtool orc:
  7. *
  8. * This command analyzes a .o file and adds .orc_unwind and .orc_unwind_ip
  9. * sections to it, which is used by the in-kernel ORC unwinder.
  10. *
  11. * This command is a superset of "objtool check".
  12. */
  13. #include <string.h>
  14. #include "builtin.h"
  15. #include "check.h"
  16. static const char *orc_usage[] = {
  17. "objtool orc generate [<options>] file.o",
  18. "objtool orc dump file.o",
  19. NULL,
  20. };
  21. int cmd_orc(int argc, const char **argv)
  22. {
  23. const char *objname;
  24. argc--; argv++;
  25. if (argc <= 0)
  26. usage_with_options(orc_usage, check_options);
  27. if (!strncmp(argv[0], "gen", 3)) {
  28. argc = parse_options(argc, argv, check_options, orc_usage, 0);
  29. if (argc != 1)
  30. usage_with_options(orc_usage, check_options);
  31. objname = argv[0];
  32. return check(objname, true);
  33. }
  34. if (!strcmp(argv[0], "dump")) {
  35. if (argc != 2)
  36. usage_with_options(orc_usage, check_options);
  37. objname = argv[1];
  38. return orc_dump(objname);
  39. }
  40. usage_with_options(orc_usage, check_options);
  41. return 0;
  42. }