recordmcount.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /*
  2. * recordmcount.h
  3. *
  4. * This code was taken out of recordmcount.c written by
  5. * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>. All rights reserved.
  6. *
  7. * The original code had the same algorithms for both 32bit
  8. * and 64bit ELF files, but the code was duplicated to support
  9. * the difference in structures that were used. This
  10. * file creates a macro of everything that is different between
  11. * the 64 and 32 bit code, such that by including this header
  12. * twice we can create both sets of functions by including this
  13. * header once with RECORD_MCOUNT_64 undefined, and again with
  14. * it defined.
  15. *
  16. * This conversion to macros was done by:
  17. * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
  18. *
  19. * Licensed under the GNU General Public License, version 2 (GPLv2).
  20. */
  21. #undef append_func
  22. #undef is_fake_mcount
  23. #undef fn_is_fake_mcount
  24. #undef MIPS_is_fake_mcount
  25. #undef sift_rel_mcount
  26. #undef nop_mcount
  27. #undef find_secsym_ndx
  28. #undef __has_rel_mcount
  29. #undef has_rel_mcount
  30. #undef tot_relsize
  31. #undef get_mcountsym
  32. #undef do_func
  33. #undef Elf_Addr
  34. #undef Elf_Ehdr
  35. #undef Elf_Shdr
  36. #undef Elf_Rel
  37. #undef Elf_Rela
  38. #undef Elf_Sym
  39. #undef ELF_R_SYM
  40. #undef Elf_r_sym
  41. #undef ELF_R_INFO
  42. #undef Elf_r_info
  43. #undef ELF_ST_BIND
  44. #undef fn_ELF_R_SYM
  45. #undef fn_ELF_R_INFO
  46. #undef uint_t
  47. #undef _w
  48. #undef _align
  49. #undef _size
  50. #ifdef RECORD_MCOUNT_64
  51. # define append_func append64
  52. # define sift_rel_mcount sift64_rel_mcount
  53. # define nop_mcount nop_mcount_64
  54. # define find_secsym_ndx find64_secsym_ndx
  55. # define __has_rel_mcount __has64_rel_mcount
  56. # define has_rel_mcount has64_rel_mcount
  57. # define tot_relsize tot64_relsize
  58. # define do_func do64
  59. # define get_mcountsym get_mcountsym_64
  60. # define is_fake_mcount is_fake_mcount64
  61. # define fn_is_fake_mcount fn_is_fake_mcount64
  62. # define MIPS_is_fake_mcount MIPS64_is_fake_mcount
  63. # define Elf_Addr Elf64_Addr
  64. # define Elf_Ehdr Elf64_Ehdr
  65. # define Elf_Shdr Elf64_Shdr
  66. # define Elf_Rel Elf64_Rel
  67. # define Elf_Rela Elf64_Rela
  68. # define Elf_Sym Elf64_Sym
  69. # define ELF_R_SYM ELF64_R_SYM
  70. # define Elf_r_sym Elf64_r_sym
  71. # define ELF_R_INFO ELF64_R_INFO
  72. # define Elf_r_info Elf64_r_info
  73. # define ELF_ST_BIND ELF64_ST_BIND
  74. # define fn_ELF_R_SYM fn_ELF64_R_SYM
  75. # define fn_ELF_R_INFO fn_ELF64_R_INFO
  76. # define uint_t uint64_t
  77. # define _w w8
  78. # define _align 7u
  79. # define _size 8
  80. #else
  81. # define append_func append32
  82. # define sift_rel_mcount sift32_rel_mcount
  83. # define nop_mcount nop_mcount_32
  84. # define find_secsym_ndx find32_secsym_ndx
  85. # define __has_rel_mcount __has32_rel_mcount
  86. # define has_rel_mcount has32_rel_mcount
  87. # define tot_relsize tot32_relsize
  88. # define do_func do32
  89. # define get_mcountsym get_mcountsym_32
  90. # define is_fake_mcount is_fake_mcount32
  91. # define fn_is_fake_mcount fn_is_fake_mcount32
  92. # define MIPS_is_fake_mcount MIPS32_is_fake_mcount
  93. # define Elf_Addr Elf32_Addr
  94. # define Elf_Ehdr Elf32_Ehdr
  95. # define Elf_Shdr Elf32_Shdr
  96. # define Elf_Rel Elf32_Rel
  97. # define Elf_Rela Elf32_Rela
  98. # define Elf_Sym Elf32_Sym
  99. # define ELF_R_SYM ELF32_R_SYM
  100. # define Elf_r_sym Elf32_r_sym
  101. # define ELF_R_INFO ELF32_R_INFO
  102. # define Elf_r_info Elf32_r_info
  103. # define ELF_ST_BIND ELF32_ST_BIND
  104. # define fn_ELF_R_SYM fn_ELF32_R_SYM
  105. # define fn_ELF_R_INFO fn_ELF32_R_INFO
  106. # define uint_t uint32_t
  107. # define _w w
  108. # define _align 3u
  109. # define _size 4
  110. #endif
  111. /* Functions and pointers that do_file() may override for specific e_machine. */
  112. static int fn_is_fake_mcount(Elf_Rel const *rp)
  113. {
  114. return 0;
  115. }
  116. static int (*is_fake_mcount)(Elf_Rel const *rp) = fn_is_fake_mcount;
  117. static uint_t fn_ELF_R_SYM(Elf_Rel const *rp)
  118. {
  119. return ELF_R_SYM(_w(rp->r_info));
  120. }
  121. static uint_t (*Elf_r_sym)(Elf_Rel const *rp) = fn_ELF_R_SYM;
  122. static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
  123. {
  124. rp->r_info = _w(ELF_R_INFO(sym, type));
  125. }
  126. static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
  127. /*
  128. * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
  129. * _mcount symbol is needed for dynamic function tracer, with it, to disable
  130. * tracing(ftrace_make_nop), the instruction in the position is replaced with
  131. * the "b label" instruction, to enable tracing(ftrace_make_call), replace the
  132. * instruction back. So, here, we set the 2nd one as fake and filter it.
  133. *
  134. * c: 3c030000 lui v1,0x0 <--> b label
  135. * c: R_MIPS_HI16 _mcount
  136. * c: R_MIPS_NONE *ABS*
  137. * c: R_MIPS_NONE *ABS*
  138. * 10: 64630000 daddiu v1,v1,0
  139. * 10: R_MIPS_LO16 _mcount
  140. * 10: R_MIPS_NONE *ABS*
  141. * 10: R_MIPS_NONE *ABS*
  142. * 14: 03e0082d move at,ra
  143. * 18: 0060f809 jalr v1
  144. * label:
  145. */
  146. #define MIPS_FAKEMCOUNT_OFFSET 4
  147. static int MIPS_is_fake_mcount(Elf_Rel const *rp)
  148. {
  149. static Elf_Addr old_r_offset;
  150. Elf_Addr current_r_offset = _w(rp->r_offset);
  151. int is_fake;
  152. is_fake = old_r_offset &&
  153. (current_r_offset - old_r_offset == MIPS_FAKEMCOUNT_OFFSET);
  154. old_r_offset = current_r_offset;
  155. return is_fake;
  156. }
  157. /* Append the new shstrtab, Elf_Shdr[], __mcount_loc and its relocations. */
  158. static void append_func(Elf_Ehdr *const ehdr,
  159. Elf_Shdr *const shstr,
  160. uint_t const *const mloc0,
  161. uint_t const *const mlocp,
  162. Elf_Rel const *const mrel0,
  163. Elf_Rel const *const mrelp,
  164. unsigned int const rel_entsize,
  165. unsigned int const symsec_sh_link)
  166. {
  167. /* Begin constructing output file */
  168. Elf_Shdr mcsec;
  169. char const *mc_name = (sizeof(Elf_Rela) == rel_entsize)
  170. ? ".rela__mcount_loc"
  171. : ".rel__mcount_loc";
  172. unsigned const old_shnum = w2(ehdr->e_shnum);
  173. uint_t const old_shoff = _w(ehdr->e_shoff);
  174. uint_t const old_shstr_sh_size = _w(shstr->sh_size);
  175. uint_t const old_shstr_sh_offset = _w(shstr->sh_offset);
  176. uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size);
  177. uint_t new_e_shoff;
  178. shstr->sh_size = _w(t);
  179. shstr->sh_offset = _w(sb.st_size);
  180. t += sb.st_size;
  181. t += (_align & -t); /* word-byte align */
  182. new_e_shoff = t;
  183. /* body for new shstrtab */
  184. ulseek(fd_map, sb.st_size, SEEK_SET);
  185. uwrite(fd_map, old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size);
  186. uwrite(fd_map, mc_name, 1 + strlen(mc_name));
  187. /* old(modified) Elf_Shdr table, word-byte aligned */
  188. ulseek(fd_map, t, SEEK_SET);
  189. t += sizeof(Elf_Shdr) * old_shnum;
  190. uwrite(fd_map, old_shoff + (void *)ehdr,
  191. sizeof(Elf_Shdr) * old_shnum);
  192. /* new sections __mcount_loc and .rel__mcount_loc */
  193. t += 2*sizeof(mcsec);
  194. mcsec.sh_name = w((sizeof(Elf_Rela) == rel_entsize) + strlen(".rel")
  195. + old_shstr_sh_size);
  196. mcsec.sh_type = w(SHT_PROGBITS);
  197. mcsec.sh_flags = _w(SHF_ALLOC);
  198. mcsec.sh_addr = 0;
  199. mcsec.sh_offset = _w(t);
  200. mcsec.sh_size = _w((void *)mlocp - (void *)mloc0);
  201. mcsec.sh_link = 0;
  202. mcsec.sh_info = 0;
  203. mcsec.sh_addralign = _w(_size);
  204. mcsec.sh_entsize = _w(_size);
  205. uwrite(fd_map, &mcsec, sizeof(mcsec));
  206. mcsec.sh_name = w(old_shstr_sh_size);
  207. mcsec.sh_type = (sizeof(Elf_Rela) == rel_entsize)
  208. ? w(SHT_RELA)
  209. : w(SHT_REL);
  210. mcsec.sh_flags = 0;
  211. mcsec.sh_addr = 0;
  212. mcsec.sh_offset = _w((void *)mlocp - (void *)mloc0 + t);
  213. mcsec.sh_size = _w((void *)mrelp - (void *)mrel0);
  214. mcsec.sh_link = w(symsec_sh_link);
  215. mcsec.sh_info = w(old_shnum);
  216. mcsec.sh_addralign = _w(_size);
  217. mcsec.sh_entsize = _w(rel_entsize);
  218. uwrite(fd_map, &mcsec, sizeof(mcsec));
  219. uwrite(fd_map, mloc0, (void *)mlocp - (void *)mloc0);
  220. uwrite(fd_map, mrel0, (void *)mrelp - (void *)mrel0);
  221. ehdr->e_shoff = _w(new_e_shoff);
  222. ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */
  223. ulseek(fd_map, 0, SEEK_SET);
  224. uwrite(fd_map, ehdr, sizeof(*ehdr));
  225. }
  226. static unsigned get_mcountsym(Elf_Sym const *const sym0,
  227. Elf_Rel const *relp,
  228. char const *const str0)
  229. {
  230. unsigned mcountsym = 0;
  231. Elf_Sym const *const symp =
  232. &sym0[Elf_r_sym(relp)];
  233. char const *symname = &str0[w(symp->st_name)];
  234. char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
  235. if (symname[0] == '.')
  236. ++symname; /* ppc64 hack */
  237. if (strcmp(mcount, symname) == 0 ||
  238. (altmcount && strcmp(altmcount, symname) == 0))
  239. mcountsym = Elf_r_sym(relp);
  240. return mcountsym;
  241. }
  242. /*
  243. * Look at the relocations in order to find the calls to mcount.
  244. * Accumulate the section offsets that are found, and their relocation info,
  245. * onto the end of the existing arrays.
  246. */
  247. static uint_t *sift_rel_mcount(uint_t *mlocp,
  248. unsigned const offbase,
  249. Elf_Rel **const mrelpp,
  250. Elf_Shdr const *const relhdr,
  251. Elf_Ehdr const *const ehdr,
  252. unsigned const recsym,
  253. uint_t const recval,
  254. unsigned const reltype)
  255. {
  256. uint_t *const mloc0 = mlocp;
  257. Elf_Rel *mrelp = *mrelpp;
  258. Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
  259. + (void *)ehdr);
  260. unsigned const symsec_sh_link = w(relhdr->sh_link);
  261. Elf_Shdr const *const symsec = &shdr0[symsec_sh_link];
  262. Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symsec->sh_offset)
  263. + (void *)ehdr);
  264. Elf_Shdr const *const strsec = &shdr0[w(symsec->sh_link)];
  265. char const *const str0 = (char const *)(_w(strsec->sh_offset)
  266. + (void *)ehdr);
  267. Elf_Rel const *const rel0 = (Elf_Rel const *)(_w(relhdr->sh_offset)
  268. + (void *)ehdr);
  269. unsigned rel_entsize = _w(relhdr->sh_entsize);
  270. unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
  271. Elf_Rel const *relp = rel0;
  272. unsigned mcountsym = 0;
  273. unsigned t;
  274. for (t = nrel; t; --t) {
  275. if (!mcountsym)
  276. mcountsym = get_mcountsym(sym0, relp, str0);
  277. if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
  278. uint_t const addend = _w(_w(relp->r_offset) - recval);
  279. mrelp->r_offset = _w(offbase
  280. + ((void *)mlocp - (void *)mloc0));
  281. Elf_r_info(mrelp, recsym, reltype);
  282. if (rel_entsize == sizeof(Elf_Rela)) {
  283. ((Elf_Rela *)mrelp)->r_addend = addend;
  284. *mlocp++ = 0;
  285. } else
  286. *mlocp++ = addend;
  287. mrelp = (Elf_Rel *)(rel_entsize + (void *)mrelp);
  288. }
  289. relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
  290. }
  291. *mrelpp = mrelp;
  292. return mlocp;
  293. }
  294. /*
  295. * Read the relocation table again, but this time its called on sections
  296. * that are not going to be traced. The mcount calls here will be converted
  297. * into nops.
  298. */
  299. static void nop_mcount(Elf_Shdr const *const relhdr,
  300. Elf_Ehdr const *const ehdr,
  301. const char *const txtname)
  302. {
  303. Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
  304. + (void *)ehdr);
  305. unsigned const symsec_sh_link = w(relhdr->sh_link);
  306. Elf_Shdr const *const symsec = &shdr0[symsec_sh_link];
  307. Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symsec->sh_offset)
  308. + (void *)ehdr);
  309. Elf_Shdr const *const strsec = &shdr0[w(symsec->sh_link)];
  310. char const *const str0 = (char const *)(_w(strsec->sh_offset)
  311. + (void *)ehdr);
  312. Elf_Rel const *const rel0 = (Elf_Rel const *)(_w(relhdr->sh_offset)
  313. + (void *)ehdr);
  314. unsigned rel_entsize = _w(relhdr->sh_entsize);
  315. unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
  316. Elf_Rel const *relp = rel0;
  317. Elf_Shdr const *const shdr = &shdr0[w(relhdr->sh_info)];
  318. unsigned mcountsym = 0;
  319. unsigned t;
  320. int once = 0;
  321. for (t = nrel; t; --t) {
  322. int ret = -1;
  323. if (!mcountsym)
  324. mcountsym = get_mcountsym(sym0, relp, str0);
  325. if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
  326. if (make_nop)
  327. ret = make_nop((void *)ehdr, shdr->sh_offset + relp->r_offset);
  328. if (warn_on_notrace_sect && !once) {
  329. printf("Section %s has mcount callers being ignored\n",
  330. txtname);
  331. once = 1;
  332. /* just warn? */
  333. if (!make_nop)
  334. return;
  335. }
  336. }
  337. /*
  338. * If we successfully removed the mcount, mark the relocation
  339. * as a nop (don't do anything with it).
  340. */
  341. if (!ret) {
  342. Elf_Rel rel;
  343. rel = *(Elf_Rel *)relp;
  344. Elf_r_info(&rel, Elf_r_sym(relp), rel_type_nop);
  345. ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
  346. uwrite(fd_map, &rel, sizeof(rel));
  347. }
  348. relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
  349. }
  350. }
  351. /*
  352. * Find a symbol in the given section, to be used as the base for relocating
  353. * the table of offsets of calls to mcount. A local or global symbol suffices,
  354. * but avoid a Weak symbol because it may be overridden; the change in value
  355. * would invalidate the relocations of the offsets of the calls to mcount.
  356. * Often the found symbol will be the unnamed local symbol generated by
  357. * GNU 'as' for the start of each section. For example:
  358. * Num: Value Size Type Bind Vis Ndx Name
  359. * 2: 00000000 0 SECTION LOCAL DEFAULT 1
  360. */
  361. static unsigned find_secsym_ndx(unsigned const txtndx,
  362. char const *const txtname,
  363. uint_t *const recvalp,
  364. Elf_Shdr const *const symhdr,
  365. Elf_Ehdr const *const ehdr)
  366. {
  367. Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symhdr->sh_offset)
  368. + (void *)ehdr);
  369. unsigned const nsym = _w(symhdr->sh_size) / _w(symhdr->sh_entsize);
  370. Elf_Sym const *symp;
  371. unsigned t;
  372. for (symp = sym0, t = nsym; t; --t, ++symp) {
  373. unsigned int const st_bind = ELF_ST_BIND(symp->st_info);
  374. if (txtndx == w2(symp->st_shndx)
  375. /* avoid STB_WEAK */
  376. && (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) {
  377. *recvalp = _w(symp->st_value);
  378. return symp - sym0;
  379. }
  380. }
  381. fprintf(stderr, "Cannot find symbol for section %d: %s.\n",
  382. txtndx, txtname);
  383. fail_file();
  384. }
  385. /* Evade ISO C restriction: no declaration after statement in has_rel_mcount. */
  386. static char const *
  387. __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */
  388. Elf_Shdr const *const shdr0,
  389. char const *const shstrtab,
  390. char const *const fname)
  391. {
  392. /* .sh_info depends on .sh_type == SHT_REL[,A] */
  393. Elf_Shdr const *const txthdr = &shdr0[w(relhdr->sh_info)];
  394. char const *const txtname = &shstrtab[w(txthdr->sh_name)];
  395. if (strcmp("__mcount_loc", txtname) == 0) {
  396. fprintf(stderr, "warning: __mcount_loc already exists: %s\n",
  397. fname);
  398. succeed_file();
  399. }
  400. if (w(txthdr->sh_type) != SHT_PROGBITS ||
  401. !(w(txthdr->sh_flags) & SHF_EXECINSTR))
  402. return NULL;
  403. return txtname;
  404. }
  405. static char const *has_rel_mcount(Elf_Shdr const *const relhdr,
  406. Elf_Shdr const *const shdr0,
  407. char const *const shstrtab,
  408. char const *const fname)
  409. {
  410. if (w(relhdr->sh_type) != SHT_REL && w(relhdr->sh_type) != SHT_RELA)
  411. return NULL;
  412. return __has_rel_mcount(relhdr, shdr0, shstrtab, fname);
  413. }
  414. static unsigned tot_relsize(Elf_Shdr const *const shdr0,
  415. unsigned nhdr,
  416. const char *const shstrtab,
  417. const char *const fname)
  418. {
  419. unsigned totrelsz = 0;
  420. Elf_Shdr const *shdrp = shdr0;
  421. char const *txtname;
  422. for (; nhdr; --nhdr, ++shdrp) {
  423. txtname = has_rel_mcount(shdrp, shdr0, shstrtab, fname);
  424. if (txtname && is_mcounted_section_name(txtname))
  425. totrelsz += _w(shdrp->sh_size);
  426. }
  427. return totrelsz;
  428. }
  429. /* Overall supervision for Elf32 ET_REL file. */
  430. static void
  431. do_func(Elf_Ehdr *const ehdr, char const *const fname, unsigned const reltype)
  432. {
  433. Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
  434. + (void *)ehdr);
  435. unsigned const nhdr = w2(ehdr->e_shnum);
  436. Elf_Shdr *const shstr = &shdr0[w2(ehdr->e_shstrndx)];
  437. char const *const shstrtab = (char const *)(_w(shstr->sh_offset)
  438. + (void *)ehdr);
  439. Elf_Shdr const *relhdr;
  440. unsigned k;
  441. /* Upper bound on space: assume all relevant relocs are for mcount. */
  442. unsigned const totrelsz = tot_relsize(shdr0, nhdr, shstrtab, fname);
  443. Elf_Rel *const mrel0 = umalloc(totrelsz);
  444. Elf_Rel * mrelp = mrel0;
  445. /* 2*sizeof(address) <= sizeof(Elf_Rel) */
  446. uint_t *const mloc0 = umalloc(totrelsz>>1);
  447. uint_t * mlocp = mloc0;
  448. unsigned rel_entsize = 0;
  449. unsigned symsec_sh_link = 0;
  450. for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) {
  451. char const *const txtname = has_rel_mcount(relhdr, shdr0,
  452. shstrtab, fname);
  453. if (txtname && is_mcounted_section_name(txtname)) {
  454. uint_t recval = 0;
  455. unsigned const recsym = find_secsym_ndx(
  456. w(relhdr->sh_info), txtname, &recval,
  457. &shdr0[symsec_sh_link = w(relhdr->sh_link)],
  458. ehdr);
  459. rel_entsize = _w(relhdr->sh_entsize);
  460. mlocp = sift_rel_mcount(mlocp,
  461. (void *)mlocp - (void *)mloc0, &mrelp,
  462. relhdr, ehdr, recsym, recval, reltype);
  463. } else if (txtname && (warn_on_notrace_sect || make_nop)) {
  464. /*
  465. * This section is ignored by ftrace, but still
  466. * has mcount calls. Convert them to nops now.
  467. */
  468. nop_mcount(relhdr, ehdr, txtname);
  469. }
  470. }
  471. if (mloc0 != mlocp) {
  472. append_func(ehdr, shstr, mloc0, mlocp, mrel0, mrelp,
  473. rel_entsize, symsec_sh_link);
  474. }
  475. free(mrel0);
  476. free(mloc0);
  477. }