Back to home page

LXR

 
 

    


0001 /*
0002  * recordmcount.h
0003  *
0004  * This code was taken out of recordmcount.c written by
0005  * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>.  All rights reserved.
0006  *
0007  * The original code had the same algorithms for both 32bit
0008  * and 64bit ELF files, but the code was duplicated to support
0009  * the difference in structures that were used. This
0010  * file creates a macro of everything that is different between
0011  * the 64 and 32 bit code, such that by including this header
0012  * twice we can create both sets of functions by including this
0013  * header once with RECORD_MCOUNT_64 undefined, and again with
0014  * it defined.
0015  *
0016  * This conversion to macros was done by:
0017  * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
0018  *
0019  * Licensed under the GNU General Public License, version 2 (GPLv2).
0020  */
0021 #undef append_func
0022 #undef is_fake_mcount
0023 #undef fn_is_fake_mcount
0024 #undef MIPS_is_fake_mcount
0025 #undef mcount_adjust
0026 #undef sift_rel_mcount
0027 #undef nop_mcount
0028 #undef find_secsym_ndx
0029 #undef __has_rel_mcount
0030 #undef has_rel_mcount
0031 #undef tot_relsize
0032 #undef get_mcountsym
0033 #undef get_sym_str_and_relp
0034 #undef do_func
0035 #undef Elf_Addr
0036 #undef Elf_Ehdr
0037 #undef Elf_Shdr
0038 #undef Elf_Rel
0039 #undef Elf_Rela
0040 #undef Elf_Sym
0041 #undef ELF_R_SYM
0042 #undef Elf_r_sym
0043 #undef ELF_R_INFO
0044 #undef Elf_r_info
0045 #undef ELF_ST_BIND
0046 #undef ELF_ST_TYPE
0047 #undef fn_ELF_R_SYM
0048 #undef fn_ELF_R_INFO
0049 #undef uint_t
0050 #undef _w
0051 #undef _align
0052 #undef _size
0053 
0054 #ifdef RECORD_MCOUNT_64
0055 # define append_func        append64
0056 # define sift_rel_mcount    sift64_rel_mcount
0057 # define nop_mcount     nop_mcount_64
0058 # define find_secsym_ndx    find64_secsym_ndx
0059 # define __has_rel_mcount   __has64_rel_mcount
0060 # define has_rel_mcount     has64_rel_mcount
0061 # define tot_relsize        tot64_relsize
0062 # define get_sym_str_and_relp   get_sym_str_and_relp_64
0063 # define do_func        do64
0064 # define get_mcountsym      get_mcountsym_64
0065 # define is_fake_mcount     is_fake_mcount64
0066 # define fn_is_fake_mcount  fn_is_fake_mcount64
0067 # define MIPS_is_fake_mcount    MIPS64_is_fake_mcount
0068 # define mcount_adjust      mcount_adjust_64
0069 # define Elf_Addr       Elf64_Addr
0070 # define Elf_Ehdr       Elf64_Ehdr
0071 # define Elf_Shdr       Elf64_Shdr
0072 # define Elf_Rel        Elf64_Rel
0073 # define Elf_Rela       Elf64_Rela
0074 # define Elf_Sym        Elf64_Sym
0075 # define ELF_R_SYM      ELF64_R_SYM
0076 # define Elf_r_sym      Elf64_r_sym
0077 # define ELF_R_INFO     ELF64_R_INFO
0078 # define Elf_r_info     Elf64_r_info
0079 # define ELF_ST_BIND        ELF64_ST_BIND
0080 # define ELF_ST_TYPE        ELF64_ST_TYPE
0081 # define fn_ELF_R_SYM       fn_ELF64_R_SYM
0082 # define fn_ELF_R_INFO      fn_ELF64_R_INFO
0083 # define uint_t         uint64_t
0084 # define _w         w8
0085 # define _align         7u
0086 # define _size          8
0087 #else
0088 # define append_func        append32
0089 # define sift_rel_mcount    sift32_rel_mcount
0090 # define nop_mcount     nop_mcount_32
0091 # define find_secsym_ndx    find32_secsym_ndx
0092 # define __has_rel_mcount   __has32_rel_mcount
0093 # define has_rel_mcount     has32_rel_mcount
0094 # define tot_relsize        tot32_relsize
0095 # define get_sym_str_and_relp   get_sym_str_and_relp_32
0096 # define do_func        do32
0097 # define get_mcountsym      get_mcountsym_32
0098 # define is_fake_mcount     is_fake_mcount32
0099 # define fn_is_fake_mcount  fn_is_fake_mcount32
0100 # define MIPS_is_fake_mcount    MIPS32_is_fake_mcount
0101 # define mcount_adjust      mcount_adjust_32
0102 # define Elf_Addr       Elf32_Addr
0103 # define Elf_Ehdr       Elf32_Ehdr
0104 # define Elf_Shdr       Elf32_Shdr
0105 # define Elf_Rel        Elf32_Rel
0106 # define Elf_Rela       Elf32_Rela
0107 # define Elf_Sym        Elf32_Sym
0108 # define ELF_R_SYM      ELF32_R_SYM
0109 # define Elf_r_sym      Elf32_r_sym
0110 # define ELF_R_INFO     ELF32_R_INFO
0111 # define Elf_r_info     Elf32_r_info
0112 # define ELF_ST_BIND        ELF32_ST_BIND
0113 # define ELF_ST_TYPE        ELF32_ST_TYPE
0114 # define fn_ELF_R_SYM       fn_ELF32_R_SYM
0115 # define fn_ELF_R_INFO      fn_ELF32_R_INFO
0116 # define uint_t         uint32_t
0117 # define _w         w
0118 # define _align         3u
0119 # define _size          4
0120 #endif
0121 
0122 /* Functions and pointers that do_file() may override for specific e_machine. */
0123 static int fn_is_fake_mcount(Elf_Rel const *rp)
0124 {
0125     return 0;
0126 }
0127 static int (*is_fake_mcount)(Elf_Rel const *rp) = fn_is_fake_mcount;
0128 
0129 static uint_t fn_ELF_R_SYM(Elf_Rel const *rp)
0130 {
0131     return ELF_R_SYM(_w(rp->r_info));
0132 }
0133 static uint_t (*Elf_r_sym)(Elf_Rel const *rp) = fn_ELF_R_SYM;
0134 
0135 static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
0136 {
0137     rp->r_info = _w(ELF_R_INFO(sym, type));
0138 }
0139 static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
0140 
0141 static int mcount_adjust = 0;
0142 
0143 /*
0144  * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
0145  * _mcount symbol is needed for dynamic function tracer, with it, to disable
0146  * tracing(ftrace_make_nop), the instruction in the position is replaced with
0147  * the "b label" instruction, to enable tracing(ftrace_make_call), replace the
0148  * instruction back. So, here, we set the 2nd one as fake and filter it.
0149  *
0150  * c:   3c030000    lui v1,0x0      <-->    b   label
0151  *      c: R_MIPS_HI16  _mcount
0152  *      c: R_MIPS_NONE  *ABS*
0153  *      c: R_MIPS_NONE  *ABS*
0154  * 10:  64630000    daddiu  v1,v1,0
0155  *      10: R_MIPS_LO16 _mcount
0156  *      10: R_MIPS_NONE *ABS*
0157  *      10: R_MIPS_NONE *ABS*
0158  * 14:  03e0082d    move    at,ra
0159  * 18:  0060f809    jalr    v1
0160  * label:
0161  */
0162 #define MIPS_FAKEMCOUNT_OFFSET  4
0163 
0164 static int MIPS_is_fake_mcount(Elf_Rel const *rp)
0165 {
0166     static Elf_Addr old_r_offset = ~(Elf_Addr)0;
0167     Elf_Addr current_r_offset = _w(rp->r_offset);
0168     int is_fake;
0169 
0170     is_fake = (old_r_offset != ~(Elf_Addr)0) &&
0171         (current_r_offset - old_r_offset == MIPS_FAKEMCOUNT_OFFSET);
0172     old_r_offset = current_r_offset;
0173 
0174     return is_fake;
0175 }
0176 
0177 /* Append the new shstrtab, Elf_Shdr[], __mcount_loc and its relocations. */
0178 static void append_func(Elf_Ehdr *const ehdr,
0179             Elf_Shdr *const shstr,
0180             uint_t const *const mloc0,
0181             uint_t const *const mlocp,
0182             Elf_Rel const *const mrel0,
0183             Elf_Rel const *const mrelp,
0184             unsigned int const rel_entsize,
0185             unsigned int const symsec_sh_link)
0186 {
0187     /* Begin constructing output file */
0188     Elf_Shdr mcsec;
0189     char const *mc_name = (sizeof(Elf_Rela) == rel_entsize)
0190         ? ".rela__mcount_loc"
0191         :  ".rel__mcount_loc";
0192     unsigned const old_shnum = w2(ehdr->e_shnum);
0193     uint_t const old_shoff = _w(ehdr->e_shoff);
0194     uint_t const old_shstr_sh_size   = _w(shstr->sh_size);
0195     uint_t const old_shstr_sh_offset = _w(shstr->sh_offset);
0196     uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size);
0197     uint_t new_e_shoff;
0198 
0199     shstr->sh_size = _w(t);
0200     shstr->sh_offset = _w(sb.st_size);
0201     t += sb.st_size;
0202     t += (_align & -t);  /* word-byte align */
0203     new_e_shoff = t;
0204 
0205     /* body for new shstrtab */
0206     ulseek(fd_map, sb.st_size, SEEK_SET);
0207     uwrite(fd_map, old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size);
0208     uwrite(fd_map, mc_name, 1 + strlen(mc_name));
0209 
0210     /* old(modified) Elf_Shdr table, word-byte aligned */
0211     ulseek(fd_map, t, SEEK_SET);
0212     t += sizeof(Elf_Shdr) * old_shnum;
0213     uwrite(fd_map, old_shoff + (void *)ehdr,
0214            sizeof(Elf_Shdr) * old_shnum);
0215 
0216     /* new sections __mcount_loc and .rel__mcount_loc */
0217     t += 2*sizeof(mcsec);
0218     mcsec.sh_name = w((sizeof(Elf_Rela) == rel_entsize) + strlen(".rel")
0219         + old_shstr_sh_size);
0220     mcsec.sh_type = w(SHT_PROGBITS);
0221     mcsec.sh_flags = _w(SHF_ALLOC);
0222     mcsec.sh_addr = 0;
0223     mcsec.sh_offset = _w(t);
0224     mcsec.sh_size = _w((void *)mlocp - (void *)mloc0);
0225     mcsec.sh_link = 0;
0226     mcsec.sh_info = 0;
0227     mcsec.sh_addralign = _w(_size);
0228     mcsec.sh_entsize = _w(_size);
0229     uwrite(fd_map, &mcsec, sizeof(mcsec));
0230 
0231     mcsec.sh_name = w(old_shstr_sh_size);
0232     mcsec.sh_type = (sizeof(Elf_Rela) == rel_entsize)
0233         ? w(SHT_RELA)
0234         : w(SHT_REL);
0235     mcsec.sh_flags = 0;
0236     mcsec.sh_addr = 0;
0237     mcsec.sh_offset = _w((void *)mlocp - (void *)mloc0 + t);
0238     mcsec.sh_size   = _w((void *)mrelp - (void *)mrel0);
0239     mcsec.sh_link = w(symsec_sh_link);
0240     mcsec.sh_info = w(old_shnum);
0241     mcsec.sh_addralign = _w(_size);
0242     mcsec.sh_entsize = _w(rel_entsize);
0243     uwrite(fd_map, &mcsec, sizeof(mcsec));
0244 
0245     uwrite(fd_map, mloc0, (void *)mlocp - (void *)mloc0);
0246     uwrite(fd_map, mrel0, (void *)mrelp - (void *)mrel0);
0247 
0248     ehdr->e_shoff = _w(new_e_shoff);
0249     ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum));  /* {.rel,}__mcount_loc */
0250     ulseek(fd_map, 0, SEEK_SET);
0251     uwrite(fd_map, ehdr, sizeof(*ehdr));
0252 }
0253 
0254 static unsigned get_mcountsym(Elf_Sym const *const sym0,
0255                   Elf_Rel const *relp,
0256                   char const *const str0)
0257 {
0258     unsigned mcountsym = 0;
0259 
0260     Elf_Sym const *const symp =
0261         &sym0[Elf_r_sym(relp)];
0262     char const *symname = &str0[w(symp->st_name)];
0263     char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
0264     char const *fentry = "__fentry__";
0265 
0266     if (symname[0] == '.')
0267         ++symname;  /* ppc64 hack */
0268     if (strcmp(mcount, symname) == 0 ||
0269         (altmcount && strcmp(altmcount, symname) == 0) ||
0270         (strcmp(fentry, symname) == 0))
0271         mcountsym = Elf_r_sym(relp);
0272 
0273     return mcountsym;
0274 }
0275 
0276 static void get_sym_str_and_relp(Elf_Shdr const *const relhdr,
0277                  Elf_Ehdr const *const ehdr,
0278                  Elf_Sym const **sym0,
0279                  char const **str0,
0280                  Elf_Rel const **relp)
0281 {
0282     Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
0283         + (void *)ehdr);
0284     unsigned const symsec_sh_link = w(relhdr->sh_link);
0285     Elf_Shdr const *const symsec = &shdr0[symsec_sh_link];
0286     Elf_Shdr const *const strsec = &shdr0[w(symsec->sh_link)];
0287     Elf_Rel const *const rel0 = (Elf_Rel const *)(_w(relhdr->sh_offset)
0288         + (void *)ehdr);
0289 
0290     *sym0 = (Elf_Sym const *)(_w(symsec->sh_offset)
0291                   + (void *)ehdr);
0292 
0293     *str0 = (char const *)(_w(strsec->sh_offset)
0294                    + (void *)ehdr);
0295 
0296     *relp = rel0;
0297 }
0298 
0299 /*
0300  * Look at the relocations in order to find the calls to mcount.
0301  * Accumulate the section offsets that are found, and their relocation info,
0302  * onto the end of the existing arrays.
0303  */
0304 static uint_t *sift_rel_mcount(uint_t *mlocp,
0305                    unsigned const offbase,
0306                    Elf_Rel **const mrelpp,
0307                    Elf_Shdr const *const relhdr,
0308                    Elf_Ehdr const *const ehdr,
0309                    unsigned const recsym,
0310                    uint_t const recval,
0311                    unsigned const reltype)
0312 {
0313     uint_t *const mloc0 = mlocp;
0314     Elf_Rel *mrelp = *mrelpp;
0315     Elf_Sym const *sym0;
0316     char const *str0;
0317     Elf_Rel const *relp;
0318     unsigned rel_entsize = _w(relhdr->sh_entsize);
0319     unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
0320     unsigned mcountsym = 0;
0321     unsigned t;
0322 
0323     get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp);
0324 
0325     for (t = nrel; t; --t) {
0326         if (!mcountsym)
0327             mcountsym = get_mcountsym(sym0, relp, str0);
0328 
0329         if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
0330             uint_t const addend =
0331                 _w(_w(relp->r_offset) - recval + mcount_adjust);
0332             mrelp->r_offset = _w(offbase
0333                 + ((void *)mlocp - (void *)mloc0));
0334             Elf_r_info(mrelp, recsym, reltype);
0335             if (rel_entsize == sizeof(Elf_Rela)) {
0336                 ((Elf_Rela *)mrelp)->r_addend = addend;
0337                 *mlocp++ = 0;
0338             } else
0339                 *mlocp++ = addend;
0340 
0341             mrelp = (Elf_Rel *)(rel_entsize + (void *)mrelp);
0342         }
0343         relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
0344     }
0345     *mrelpp = mrelp;
0346     return mlocp;
0347 }
0348 
0349 /*
0350  * Read the relocation table again, but this time its called on sections
0351  * that are not going to be traced. The mcount calls here will be converted
0352  * into nops.
0353  */
0354 static void nop_mcount(Elf_Shdr const *const relhdr,
0355                Elf_Ehdr const *const ehdr,
0356                const char *const txtname)
0357 {
0358     Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
0359         + (void *)ehdr);
0360     Elf_Sym const *sym0;
0361     char const *str0;
0362     Elf_Rel const *relp;
0363     Elf_Shdr const *const shdr = &shdr0[w(relhdr->sh_info)];
0364     unsigned rel_entsize = _w(relhdr->sh_entsize);
0365     unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
0366     unsigned mcountsym = 0;
0367     unsigned t;
0368     int once = 0;
0369 
0370     get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp);
0371 
0372     for (t = nrel; t; --t) {
0373         int ret = -1;
0374 
0375         if (!mcountsym)
0376             mcountsym = get_mcountsym(sym0, relp, str0);
0377 
0378         if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
0379             if (make_nop)
0380                 ret = make_nop((void *)ehdr, _w(shdr->sh_offset) + _w(relp->r_offset));
0381             if (warn_on_notrace_sect && !once) {
0382                 printf("Section %s has mcount callers being ignored\n",
0383                        txtname);
0384                 once = 1;
0385                 /* just warn? */
0386                 if (!make_nop)
0387                     return;
0388             }
0389         }
0390 
0391         /*
0392          * If we successfully removed the mcount, mark the relocation
0393          * as a nop (don't do anything with it).
0394          */
0395         if (!ret) {
0396             Elf_Rel rel;
0397             rel = *(Elf_Rel *)relp;
0398             Elf_r_info(&rel, Elf_r_sym(relp), rel_type_nop);
0399             ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
0400             uwrite(fd_map, &rel, sizeof(rel));
0401         }
0402         relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
0403     }
0404 }
0405 
0406 
0407 /*
0408  * Find a symbol in the given section, to be used as the base for relocating
0409  * the table of offsets of calls to mcount.  A local or global symbol suffices,
0410  * but avoid a Weak symbol because it may be overridden; the change in value
0411  * would invalidate the relocations of the offsets of the calls to mcount.
0412  * Often the found symbol will be the unnamed local symbol generated by
0413  * GNU 'as' for the start of each section.  For example:
0414  *    Num:    Value  Size Type    Bind   Vis      Ndx Name
0415  *      2: 00000000     0 SECTION LOCAL  DEFAULT    1
0416  */
0417 static unsigned find_secsym_ndx(unsigned const txtndx,
0418                 char const *const txtname,
0419                 uint_t *const recvalp,
0420                 Elf_Shdr const *const symhdr,
0421                 Elf_Ehdr const *const ehdr)
0422 {
0423     Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symhdr->sh_offset)
0424         + (void *)ehdr);
0425     unsigned const nsym = _w(symhdr->sh_size) / _w(symhdr->sh_entsize);
0426     Elf_Sym const *symp;
0427     unsigned t;
0428 
0429     for (symp = sym0, t = nsym; t; --t, ++symp) {
0430         unsigned int const st_bind = ELF_ST_BIND(symp->st_info);
0431 
0432         if (txtndx == w2(symp->st_shndx)
0433             /* avoid STB_WEAK */
0434             && (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) {
0435             /* function symbols on ARM have quirks, avoid them */
0436             if (w2(ehdr->e_machine) == EM_ARM
0437                 && ELF_ST_TYPE(symp->st_info) == STT_FUNC)
0438                 continue;
0439 
0440             *recvalp = _w(symp->st_value);
0441             return symp - sym0;
0442         }
0443     }
0444     fprintf(stderr, "Cannot find symbol for section %d: %s.\n",
0445         txtndx, txtname);
0446     fail_file();
0447 }
0448 
0449 
0450 /* Evade ISO C restriction: no declaration after statement in has_rel_mcount. */
0451 static char const *
0452 __has_rel_mcount(Elf_Shdr const *const relhdr,  /* is SHT_REL or SHT_RELA */
0453          Elf_Shdr const *const shdr0,
0454          char const *const shstrtab,
0455          char const *const fname)
0456 {
0457     /* .sh_info depends on .sh_type == SHT_REL[,A] */
0458     Elf_Shdr const *const txthdr = &shdr0[w(relhdr->sh_info)];
0459     char const *const txtname = &shstrtab[w(txthdr->sh_name)];
0460 
0461     if (strcmp("__mcount_loc", txtname) == 0) {
0462         fprintf(stderr, "warning: __mcount_loc already exists: %s\n",
0463             fname);
0464         succeed_file();
0465     }
0466     if (w(txthdr->sh_type) != SHT_PROGBITS ||
0467         !(_w(txthdr->sh_flags) & SHF_EXECINSTR))
0468         return NULL;
0469     return txtname;
0470 }
0471 
0472 static char const *has_rel_mcount(Elf_Shdr const *const relhdr,
0473                   Elf_Shdr const *const shdr0,
0474                   char const *const shstrtab,
0475                   char const *const fname)
0476 {
0477     if (w(relhdr->sh_type) != SHT_REL && w(relhdr->sh_type) != SHT_RELA)
0478         return NULL;
0479     return __has_rel_mcount(relhdr, shdr0, shstrtab, fname);
0480 }
0481 
0482 
0483 static unsigned tot_relsize(Elf_Shdr const *const shdr0,
0484                 unsigned nhdr,
0485                 const char *const shstrtab,
0486                 const char *const fname)
0487 {
0488     unsigned totrelsz = 0;
0489     Elf_Shdr const *shdrp = shdr0;
0490     char const *txtname;
0491 
0492     for (; nhdr; --nhdr, ++shdrp) {
0493         txtname = has_rel_mcount(shdrp, shdr0, shstrtab, fname);
0494         if (txtname && is_mcounted_section_name(txtname))
0495             totrelsz += _w(shdrp->sh_size);
0496     }
0497     return totrelsz;
0498 }
0499 
0500 
0501 /* Overall supervision for Elf32 ET_REL file. */
0502 static void
0503 do_func(Elf_Ehdr *const ehdr, char const *const fname, unsigned const reltype)
0504 {
0505     Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
0506         + (void *)ehdr);
0507     unsigned const nhdr = w2(ehdr->e_shnum);
0508     Elf_Shdr *const shstr = &shdr0[w2(ehdr->e_shstrndx)];
0509     char const *const shstrtab = (char const *)(_w(shstr->sh_offset)
0510         + (void *)ehdr);
0511 
0512     Elf_Shdr const *relhdr;
0513     unsigned k;
0514 
0515     /* Upper bound on space: assume all relevant relocs are for mcount. */
0516     unsigned const totrelsz = tot_relsize(shdr0, nhdr, shstrtab, fname);
0517     Elf_Rel *const mrel0 = umalloc(totrelsz);
0518     Elf_Rel *      mrelp = mrel0;
0519 
0520     /* 2*sizeof(address) <= sizeof(Elf_Rel) */
0521     uint_t *const mloc0 = umalloc(totrelsz>>1);
0522     uint_t *      mlocp = mloc0;
0523 
0524     unsigned rel_entsize = 0;
0525     unsigned symsec_sh_link = 0;
0526 
0527     for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) {
0528         char const *const txtname = has_rel_mcount(relhdr, shdr0,
0529             shstrtab, fname);
0530         if (txtname && is_mcounted_section_name(txtname)) {
0531             uint_t recval = 0;
0532             unsigned const recsym = find_secsym_ndx(
0533                 w(relhdr->sh_info), txtname, &recval,
0534                 &shdr0[symsec_sh_link = w(relhdr->sh_link)],
0535                 ehdr);
0536 
0537             rel_entsize = _w(relhdr->sh_entsize);
0538             mlocp = sift_rel_mcount(mlocp,
0539                 (void *)mlocp - (void *)mloc0, &mrelp,
0540                 relhdr, ehdr, recsym, recval, reltype);
0541         } else if (txtname && (warn_on_notrace_sect || make_nop)) {
0542             /*
0543              * This section is ignored by ftrace, but still
0544              * has mcount calls. Convert them to nops now.
0545              */
0546             nop_mcount(relhdr, ehdr, txtname);
0547         }
0548     }
0549     if (mloc0 != mlocp) {
0550         append_func(ehdr, shstr, mloc0, mlocp, mrel0, mrelp,
0551                 rel_entsize, symsec_sh_link);
0552     }
0553     free(mrel0);
0554     free(mloc0);
0555 }