/scripts/recordmcount.c

http://github.com/mirrors/linux · C · 663 lines · 521 code · 77 blank · 65 comment · 93 complexity · ed7828f81f3391c01e9fc6e48dec8b54 MD5 · raw file

  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * recordmcount.c: construct a table of the locations of calls to 'mcount'
  4. * so that ftrace can find them quickly.
  5. * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>. All rights reserved.
  6. *
  7. * Restructured to fit Linux format, as well as other updates:
  8. * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
  9. */
  10. /*
  11. * Strategy: alter the .o file in-place.
  12. *
  13. * Append a new STRTAB that has the new section names, followed by a new array
  14. * ElfXX_Shdr[] that has the new section headers, followed by the section
  15. * contents for __mcount_loc and its relocations. The old shstrtab strings,
  16. * and the old ElfXX_Shdr[] array, remain as "garbage" (commonly, a couple
  17. * kilobytes.) Subsequent processing by /bin/ld (or the kernel module loader)
  18. * will ignore the garbage regions, because they are not designated by the
  19. * new .e_shoff nor the new ElfXX_Shdr[]. [In order to remove the garbage,
  20. * then use "ld -r" to create a new file that omits the garbage.]
  21. */
  22. #include <sys/types.h>
  23. #include <sys/mman.h>
  24. #include <sys/stat.h>
  25. #include <getopt.h>
  26. #include <elf.h>
  27. #include <fcntl.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <unistd.h>
  32. #ifndef EM_AARCH64
  33. #define EM_AARCH64 183
  34. #define R_AARCH64_NONE 0
  35. #define R_AARCH64_ABS64 257
  36. #endif
  37. #define R_ARM_PC24 1
  38. #define R_ARM_THM_CALL 10
  39. #define R_ARM_CALL 28
  40. static int fd_map; /* File descriptor for file being modified. */
  41. static int mmap_failed; /* Boolean flag. */
  42. static char gpfx; /* prefix for global symbol name (sometimes '_') */
  43. static struct stat sb; /* Remember .st_size, etc. */
  44. static const char *altmcount; /* alternate mcount symbol name */
  45. static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */
  46. static void *file_map; /* pointer of the mapped file */
  47. static void *file_end; /* pointer to the end of the mapped file */
  48. static int file_updated; /* flag to state file was changed */
  49. static void *file_ptr; /* current file pointer location */
  50. static void *file_append; /* added to the end of the file */
  51. static size_t file_append_size; /* how much is added to end of file */
  52. /* Per-file resource cleanup when multiple files. */
  53. static void file_append_cleanup(void)
  54. {
  55. free(file_append);
  56. file_append = NULL;
  57. file_append_size = 0;
  58. file_updated = 0;
  59. }
  60. static void mmap_cleanup(void)
  61. {
  62. if (!mmap_failed)
  63. munmap(file_map, sb.st_size);
  64. else
  65. free(file_map);
  66. file_map = NULL;
  67. }
  68. /* ulseek, uwrite, ...: Check return value for errors. */
  69. static off_t ulseek(off_t const offset, int const whence)
  70. {
  71. switch (whence) {
  72. case SEEK_SET:
  73. file_ptr = file_map + offset;
  74. break;
  75. case SEEK_CUR:
  76. file_ptr += offset;
  77. break;
  78. case SEEK_END:
  79. file_ptr = file_map + (sb.st_size - offset);
  80. break;
  81. }
  82. if (file_ptr < file_map) {
  83. fprintf(stderr, "lseek: seek before file\n");
  84. return -1;
  85. }
  86. return file_ptr - file_map;
  87. }
  88. static ssize_t uwrite(void const *const buf, size_t const count)
  89. {
  90. size_t cnt = count;
  91. off_t idx = 0;
  92. file_updated = 1;
  93. if (file_ptr + count >= file_end) {
  94. off_t aoffset = (file_ptr + count) - file_end;
  95. if (aoffset > file_append_size) {
  96. file_append = realloc(file_append, aoffset);
  97. file_append_size = aoffset;
  98. }
  99. if (!file_append) {
  100. perror("write");
  101. file_append_cleanup();
  102. mmap_cleanup();
  103. return -1;
  104. }
  105. if (file_ptr < file_end) {
  106. cnt = file_end - file_ptr;
  107. } else {
  108. cnt = 0;
  109. idx = aoffset - count;
  110. }
  111. }
  112. if (cnt)
  113. memcpy(file_ptr, buf, cnt);
  114. if (cnt < count)
  115. memcpy(file_append + idx, buf + cnt, count - cnt);
  116. file_ptr += count;
  117. return count;
  118. }
  119. static void * umalloc(size_t size)
  120. {
  121. void *const addr = malloc(size);
  122. if (addr == 0) {
  123. fprintf(stderr, "malloc failed: %zu bytes\n", size);
  124. file_append_cleanup();
  125. mmap_cleanup();
  126. return NULL;
  127. }
  128. return addr;
  129. }
  130. /*
  131. * Get the whole file as a programming convenience in order to avoid
  132. * malloc+lseek+read+free of many pieces. If successful, then mmap
  133. * avoids copying unused pieces; else just read the whole file.
  134. * Open for both read and write; new info will be appended to the file.
  135. * Use MAP_PRIVATE so that a few changes to the in-memory ElfXX_Ehdr
  136. * do not propagate to the file until an explicit overwrite at the last.
  137. * This preserves most aspects of consistency (all except .st_size)
  138. * for simultaneous readers of the file while we are appending to it.
  139. * However, multiple writers still are bad. We choose not to use
  140. * locking because it is expensive and the use case of kernel build
  141. * makes multiple writers unlikely.
  142. */
  143. static void *mmap_file(char const *fname)
  144. {
  145. /* Avoid problems if early cleanup() */
  146. fd_map = -1;
  147. mmap_failed = 1;
  148. file_map = NULL;
  149. file_ptr = NULL;
  150. file_updated = 0;
  151. sb.st_size = 0;
  152. fd_map = open(fname, O_RDONLY);
  153. if (fd_map < 0) {
  154. perror(fname);
  155. return NULL;
  156. }
  157. if (fstat(fd_map, &sb) < 0) {
  158. perror(fname);
  159. goto out;
  160. }
  161. if (!S_ISREG(sb.st_mode)) {
  162. fprintf(stderr, "not a regular file: %s\n", fname);
  163. goto out;
  164. }
  165. file_map = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
  166. fd_map, 0);
  167. if (file_map == MAP_FAILED) {
  168. mmap_failed = 1;
  169. file_map = umalloc(sb.st_size);
  170. if (!file_map) {
  171. perror(fname);
  172. goto out;
  173. }
  174. if (read(fd_map, file_map, sb.st_size) != sb.st_size) {
  175. perror(fname);
  176. free(file_map);
  177. file_map = NULL;
  178. goto out;
  179. }
  180. } else
  181. mmap_failed = 0;
  182. out:
  183. close(fd_map);
  184. fd_map = -1;
  185. file_end = file_map + sb.st_size;
  186. return file_map;
  187. }
  188. static unsigned char ideal_nop5_x86_64[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
  189. static unsigned char ideal_nop5_x86_32[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 };
  190. static unsigned char *ideal_nop;
  191. static char rel_type_nop;
  192. static int (*make_nop)(void *map, size_t const offset);
  193. static int make_nop_x86(void *map, size_t const offset)
  194. {
  195. uint32_t *ptr;
  196. unsigned char *op;
  197. /* Confirm we have 0xe8 0x0 0x0 0x0 0x0 */
  198. ptr = map + offset;
  199. if (*ptr != 0)
  200. return -1;
  201. op = map + offset - 1;
  202. if (*op != 0xe8)
  203. return -1;
  204. /* convert to nop */
  205. if (ulseek(offset - 1, SEEK_SET) < 0)
  206. return -1;
  207. if (uwrite(ideal_nop, 5) < 0)
  208. return -1;
  209. return 0;
  210. }
  211. static unsigned char ideal_nop4_arm_le[4] = { 0x00, 0x00, 0xa0, 0xe1 }; /* mov r0, r0 */
  212. static unsigned char ideal_nop4_arm_be[4] = { 0xe1, 0xa0, 0x00, 0x00 }; /* mov r0, r0 */
  213. static unsigned char *ideal_nop4_arm;
  214. static unsigned char bl_mcount_arm_le[4] = { 0xfe, 0xff, 0xff, 0xeb }; /* bl */
  215. static unsigned char bl_mcount_arm_be[4] = { 0xeb, 0xff, 0xff, 0xfe }; /* bl */
  216. static unsigned char *bl_mcount_arm;
  217. static unsigned char push_arm_le[4] = { 0x04, 0xe0, 0x2d, 0xe5 }; /* push {lr} */
  218. static unsigned char push_arm_be[4] = { 0xe5, 0x2d, 0xe0, 0x04 }; /* push {lr} */
  219. static unsigned char *push_arm;
  220. static unsigned char ideal_nop2_thumb_le[2] = { 0x00, 0xbf }; /* nop */
  221. static unsigned char ideal_nop2_thumb_be[2] = { 0xbf, 0x00 }; /* nop */
  222. static unsigned char *ideal_nop2_thumb;
  223. static unsigned char push_bl_mcount_thumb_le[6] = { 0x00, 0xb5, 0xff, 0xf7, 0xfe, 0xff }; /* push {lr}, bl */
  224. static unsigned char push_bl_mcount_thumb_be[6] = { 0xb5, 0x00, 0xf7, 0xff, 0xff, 0xfe }; /* push {lr}, bl */
  225. static unsigned char *push_bl_mcount_thumb;
  226. static int make_nop_arm(void *map, size_t const offset)
  227. {
  228. char *ptr;
  229. int cnt = 1;
  230. int nop_size;
  231. size_t off = offset;
  232. ptr = map + offset;
  233. if (memcmp(ptr, bl_mcount_arm, 4) == 0) {
  234. if (memcmp(ptr - 4, push_arm, 4) == 0) {
  235. off -= 4;
  236. cnt = 2;
  237. }
  238. ideal_nop = ideal_nop4_arm;
  239. nop_size = 4;
  240. } else if (memcmp(ptr - 2, push_bl_mcount_thumb, 6) == 0) {
  241. cnt = 3;
  242. nop_size = 2;
  243. off -= 2;
  244. ideal_nop = ideal_nop2_thumb;
  245. } else
  246. return -1;
  247. /* Convert to nop */
  248. if (ulseek(off, SEEK_SET) < 0)
  249. return -1;
  250. do {
  251. if (uwrite(ideal_nop, nop_size) < 0)
  252. return -1;
  253. } while (--cnt > 0);
  254. return 0;
  255. }
  256. static unsigned char ideal_nop4_arm64[4] = {0x1f, 0x20, 0x03, 0xd5};
  257. static int make_nop_arm64(void *map, size_t const offset)
  258. {
  259. uint32_t *ptr;
  260. ptr = map + offset;
  261. /* bl <_mcount> is 0x94000000 before relocation */
  262. if (*ptr != 0x94000000)
  263. return -1;
  264. /* Convert to nop */
  265. if (ulseek(offset, SEEK_SET) < 0)
  266. return -1;
  267. if (uwrite(ideal_nop, 4) < 0)
  268. return -1;
  269. return 0;
  270. }
  271. static int write_file(const char *fname)
  272. {
  273. char tmp_file[strlen(fname) + 4];
  274. size_t n;
  275. if (!file_updated)
  276. return 0;
  277. sprintf(tmp_file, "%s.rc", fname);
  278. /*
  279. * After reading the entire file into memory, delete it
  280. * and write it back, to prevent weird side effects of modifying
  281. * an object file in place.
  282. */
  283. fd_map = open(tmp_file, O_WRONLY | O_TRUNC | O_CREAT, sb.st_mode);
  284. if (fd_map < 0) {
  285. perror(fname);
  286. return -1;
  287. }
  288. n = write(fd_map, file_map, sb.st_size);
  289. if (n != sb.st_size) {
  290. perror("write");
  291. close(fd_map);
  292. return -1;
  293. }
  294. if (file_append_size) {
  295. n = write(fd_map, file_append, file_append_size);
  296. if (n != file_append_size) {
  297. perror("write");
  298. close(fd_map);
  299. return -1;
  300. }
  301. }
  302. close(fd_map);
  303. if (rename(tmp_file, fname) < 0) {
  304. perror(fname);
  305. return -1;
  306. }
  307. return 0;
  308. }
  309. /* w8rev, w8nat, ...: Handle endianness. */
  310. static uint64_t w8rev(uint64_t const x)
  311. {
  312. return ((0xff & (x >> (0 * 8))) << (7 * 8))
  313. | ((0xff & (x >> (1 * 8))) << (6 * 8))
  314. | ((0xff & (x >> (2 * 8))) << (5 * 8))
  315. | ((0xff & (x >> (3 * 8))) << (4 * 8))
  316. | ((0xff & (x >> (4 * 8))) << (3 * 8))
  317. | ((0xff & (x >> (5 * 8))) << (2 * 8))
  318. | ((0xff & (x >> (6 * 8))) << (1 * 8))
  319. | ((0xff & (x >> (7 * 8))) << (0 * 8));
  320. }
  321. static uint32_t w4rev(uint32_t const x)
  322. {
  323. return ((0xff & (x >> (0 * 8))) << (3 * 8))
  324. | ((0xff & (x >> (1 * 8))) << (2 * 8))
  325. | ((0xff & (x >> (2 * 8))) << (1 * 8))
  326. | ((0xff & (x >> (3 * 8))) << (0 * 8));
  327. }
  328. static uint32_t w2rev(uint16_t const x)
  329. {
  330. return ((0xff & (x >> (0 * 8))) << (1 * 8))
  331. | ((0xff & (x >> (1 * 8))) << (0 * 8));
  332. }
  333. static uint64_t w8nat(uint64_t const x)
  334. {
  335. return x;
  336. }
  337. static uint32_t w4nat(uint32_t const x)
  338. {
  339. return x;
  340. }
  341. static uint32_t w2nat(uint16_t const x)
  342. {
  343. return x;
  344. }
  345. static uint64_t (*w8)(uint64_t);
  346. static uint32_t (*w)(uint32_t);
  347. static uint32_t (*w2)(uint16_t);
  348. /* Names of the sections that could contain calls to mcount. */
  349. static int is_mcounted_section_name(char const *const txtname)
  350. {
  351. return strncmp(".text", txtname, 5) == 0 ||
  352. strcmp(".init.text", txtname) == 0 ||
  353. strcmp(".ref.text", txtname) == 0 ||
  354. strcmp(".sched.text", txtname) == 0 ||
  355. strcmp(".spinlock.text", txtname) == 0 ||
  356. strcmp(".irqentry.text", txtname) == 0 ||
  357. strcmp(".softirqentry.text", txtname) == 0 ||
  358. strcmp(".kprobes.text", txtname) == 0 ||
  359. strcmp(".cpuidle.text", txtname) == 0;
  360. }
  361. static char const *already_has_rel_mcount = "success"; /* our work here is done! */
  362. /* 32 bit and 64 bit are very similar */
  363. #include "recordmcount.h"
  364. #define RECORD_MCOUNT_64
  365. #include "recordmcount.h"
  366. static int arm_is_fake_mcount(Elf32_Rel const *rp)
  367. {
  368. switch (ELF32_R_TYPE(w(rp->r_info))) {
  369. case R_ARM_THM_CALL:
  370. case R_ARM_CALL:
  371. case R_ARM_PC24:
  372. return 0;
  373. }
  374. return 1;
  375. }
  376. /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
  377. * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf
  378. * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40]
  379. * to imply the order of the members; the spec does not say so.
  380. * typedef unsigned char Elf64_Byte;
  381. * fails on MIPS64 because their <elf.h> already has it!
  382. */
  383. typedef uint8_t myElf64_Byte; /* Type for a 8-bit quantity. */
  384. union mips_r_info {
  385. Elf64_Xword r_info;
  386. struct {
  387. Elf64_Word r_sym; /* Symbol index. */
  388. myElf64_Byte r_ssym; /* Special symbol. */
  389. myElf64_Byte r_type3; /* Third relocation. */
  390. myElf64_Byte r_type2; /* Second relocation. */
  391. myElf64_Byte r_type; /* First relocation. */
  392. } r_mips;
  393. };
  394. static uint64_t MIPS64_r_sym(Elf64_Rel const *rp)
  395. {
  396. return w(((union mips_r_info){ .r_info = rp->r_info }).r_mips.r_sym);
  397. }
  398. static void MIPS64_r_info(Elf64_Rel *const rp, unsigned sym, unsigned type)
  399. {
  400. rp->r_info = ((union mips_r_info){
  401. .r_mips = { .r_sym = w(sym), .r_type = type }
  402. }).r_info;
  403. }
  404. static int do_file(char const *const fname)
  405. {
  406. unsigned int reltype = 0;
  407. Elf32_Ehdr *ehdr;
  408. int rc = -1;
  409. ehdr = mmap_file(fname);
  410. if (!ehdr)
  411. goto out;
  412. w = w4nat;
  413. w2 = w2nat;
  414. w8 = w8nat;
  415. switch (ehdr->e_ident[EI_DATA]) {
  416. static unsigned int const endian = 1;
  417. default:
  418. fprintf(stderr, "unrecognized ELF data encoding %d: %s\n",
  419. ehdr->e_ident[EI_DATA], fname);
  420. goto out;
  421. case ELFDATA2LSB:
  422. if (*(unsigned char const *)&endian != 1) {
  423. /* main() is big endian, file.o is little endian. */
  424. w = w4rev;
  425. w2 = w2rev;
  426. w8 = w8rev;
  427. }
  428. ideal_nop4_arm = ideal_nop4_arm_le;
  429. bl_mcount_arm = bl_mcount_arm_le;
  430. push_arm = push_arm_le;
  431. ideal_nop2_thumb = ideal_nop2_thumb_le;
  432. push_bl_mcount_thumb = push_bl_mcount_thumb_le;
  433. break;
  434. case ELFDATA2MSB:
  435. if (*(unsigned char const *)&endian != 0) {
  436. /* main() is little endian, file.o is big endian. */
  437. w = w4rev;
  438. w2 = w2rev;
  439. w8 = w8rev;
  440. }
  441. ideal_nop4_arm = ideal_nop4_arm_be;
  442. bl_mcount_arm = bl_mcount_arm_be;
  443. push_arm = push_arm_be;
  444. ideal_nop2_thumb = ideal_nop2_thumb_be;
  445. push_bl_mcount_thumb = push_bl_mcount_thumb_be;
  446. break;
  447. } /* end switch */
  448. if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 ||
  449. w2(ehdr->e_type) != ET_REL ||
  450. ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
  451. fprintf(stderr, "unrecognized ET_REL file %s\n", fname);
  452. goto out;
  453. }
  454. gpfx = '_';
  455. switch (w2(ehdr->e_machine)) {
  456. default:
  457. fprintf(stderr, "unrecognized e_machine %u %s\n",
  458. w2(ehdr->e_machine), fname);
  459. goto out;
  460. case EM_386:
  461. reltype = R_386_32;
  462. rel_type_nop = R_386_NONE;
  463. make_nop = make_nop_x86;
  464. ideal_nop = ideal_nop5_x86_32;
  465. mcount_adjust_32 = -1;
  466. gpfx = 0;
  467. break;
  468. case EM_ARM:
  469. reltype = R_ARM_ABS32;
  470. altmcount = "__gnu_mcount_nc";
  471. make_nop = make_nop_arm;
  472. rel_type_nop = R_ARM_NONE;
  473. is_fake_mcount32 = arm_is_fake_mcount;
  474. gpfx = 0;
  475. break;
  476. case EM_AARCH64:
  477. reltype = R_AARCH64_ABS64;
  478. make_nop = make_nop_arm64;
  479. rel_type_nop = R_AARCH64_NONE;
  480. ideal_nop = ideal_nop4_arm64;
  481. break;
  482. case EM_IA_64: reltype = R_IA64_IMM64; break;
  483. case EM_MIPS: /* reltype: e_class */ break;
  484. case EM_PPC: reltype = R_PPC_ADDR32; break;
  485. case EM_PPC64: reltype = R_PPC64_ADDR64; break;
  486. case EM_S390: /* reltype: e_class */ break;
  487. case EM_SH: reltype = R_SH_DIR32; gpfx = 0; break;
  488. case EM_SPARCV9: reltype = R_SPARC_64; break;
  489. case EM_X86_64:
  490. make_nop = make_nop_x86;
  491. ideal_nop = ideal_nop5_x86_64;
  492. reltype = R_X86_64_64;
  493. rel_type_nop = R_X86_64_NONE;
  494. mcount_adjust_64 = -1;
  495. gpfx = 0;
  496. break;
  497. } /* end switch */
  498. switch (ehdr->e_ident[EI_CLASS]) {
  499. default:
  500. fprintf(stderr, "unrecognized ELF class %d %s\n",
  501. ehdr->e_ident[EI_CLASS], fname);
  502. goto out;
  503. case ELFCLASS32:
  504. if (w2(ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
  505. || w2(ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
  506. fprintf(stderr,
  507. "unrecognized ET_REL file: %s\n", fname);
  508. goto out;
  509. }
  510. if (w2(ehdr->e_machine) == EM_MIPS) {
  511. reltype = R_MIPS_32;
  512. is_fake_mcount32 = MIPS32_is_fake_mcount;
  513. }
  514. if (do32(ehdr, fname, reltype) < 0)
  515. goto out;
  516. break;
  517. case ELFCLASS64: {
  518. Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr;
  519. if (w2(ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
  520. || w2(ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
  521. fprintf(stderr,
  522. "unrecognized ET_REL file: %s\n", fname);
  523. goto out;
  524. }
  525. if (w2(ghdr->e_machine) == EM_S390) {
  526. reltype = R_390_64;
  527. mcount_adjust_64 = -14;
  528. }
  529. if (w2(ghdr->e_machine) == EM_MIPS) {
  530. reltype = R_MIPS_64;
  531. Elf64_r_sym = MIPS64_r_sym;
  532. Elf64_r_info = MIPS64_r_info;
  533. is_fake_mcount64 = MIPS64_is_fake_mcount;
  534. }
  535. if (do64(ghdr, fname, reltype) < 0)
  536. goto out;
  537. break;
  538. }
  539. } /* end switch */
  540. rc = write_file(fname);
  541. out:
  542. file_append_cleanup();
  543. mmap_cleanup();
  544. return rc;
  545. }
  546. int main(int argc, char *argv[])
  547. {
  548. const char ftrace[] = "/ftrace.o";
  549. int ftrace_size = sizeof(ftrace) - 1;
  550. int n_error = 0; /* gcc-4.3.0 false positive complaint */
  551. int c;
  552. int i;
  553. while ((c = getopt(argc, argv, "w")) >= 0) {
  554. switch (c) {
  555. case 'w':
  556. warn_on_notrace_sect = 1;
  557. break;
  558. default:
  559. fprintf(stderr, "usage: recordmcount [-w] file.o...\n");
  560. return 0;
  561. }
  562. }
  563. if ((argc - optind) < 1) {
  564. fprintf(stderr, "usage: recordmcount [-w] file.o...\n");
  565. return 0;
  566. }
  567. /* Process each file in turn, allowing deep failure. */
  568. for (i = optind; i < argc; i++) {
  569. char *file = argv[i];
  570. int len;
  571. /*
  572. * The file kernel/trace/ftrace.o references the mcount
  573. * function but does not call it. Since ftrace.o should
  574. * not be traced anyway, we just skip it.
  575. */
  576. len = strlen(file);
  577. if (len >= ftrace_size &&
  578. strcmp(file + (len - ftrace_size), ftrace) == 0)
  579. continue;
  580. if (do_file(file)) {
  581. fprintf(stderr, "%s: failed\n", file);
  582. ++n_error;
  583. }
  584. }
  585. return !!n_error;
  586. }