recordmcount.h 16 KB

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