linux/scripts/recordmcount.c
<<
> opt/spa opt/form opta > op href="../linux+v3.7.5/scripts/recordmcount.c"> > optimg src="../.static/gfx/right.png" alt=">>"> >t/spa >tspa class="lxr_search"> > ="+search" method="post" onsubmit="return do_search(this);"> > optinput typv2.hidden" namv2.navtarget" ue="v2."> > optinput typv2.text" namv2.search" id2.search"> > optbuttvaltypv2.submit">Searchtspa class="lxr_prefs" opta href="+prefs?return=scripts/recordmcount.c" > op onclick="return ajax_prefs();"> > opPrefs opt/a> >t/spa op pt/div op ptform acn> ="ajax+*" method="post" onsubmit="return false;"> >tinput typv2.hidden" namv2.ajax_lookup" id2.ajax_lookup" ue="v2."> op pt/form op ptdiv class="headingbottvm">
tdiv id2.file_contents"
p p1t/a>tspa  class="comment">/*t/spa  
p p2t/a>tspa  class="comment"> * recordmcount.c: construct a table of the locan>
 s of calls to 'mcount't/spa  
p p3t/a>tspa  class="comment"> * so that ftrace ca  find them quickly.t/spa  
p p4t/a>tspa  class="comment"> * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>.  All rights reserved.t/spa  
p p5t/a>tspa  class="comment"> * Licensed under the GNU General Public License, vers val2 (GPLv2).t/spa  
p p6t/a>tspa  class="comment"> *t/spa  
p p7t/a>tspa  class="comment"> * Restructured to fit Linux format, as well as other updates:t/spa  
p p8t/a>tspa  class="comment"> *  Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.t/spa  
p p9t/a>tspa  class="comment"> */t/spa  
p /opta 
p 11t/a>tspa  class="comment">/*t/spa  
p 12t/a>tspa  class="comment"> * Strategy: alter the .o file in-place.t/spa  
p 13t/a>tspa  class="comment"> *t/spa  
p 14t/a>tspa  class="comment"> * Append a new STRTAB that has the new secn>
  namvs, followed by a new arrayt/spa  
p 15t/a>tspa  class="comment"> * ElfXX_Shdr[] that has the new secn>
  headers, followed by the secn>
 t/spa  
p 16t/a>tspa  class="comment"> * contents for __mcount_loc and its relocan>
 s.  The old shstrtab strings,t/spa  
p 17t/a>tspa  class="comment"> * and the old ElfXX_Shdr[] array, remain as "garbage" (commonly, a couplet/spa  
p 18t/a>tspa  class="comment"> * kilobytes.)  Subsequent processing by /bin/ld (or the kernel module loader)t/spa  
p 19t/a>tspa  class="comment"> * will ignore the garbage reg>
 s, because they are not designated by thet/spa  
p 20t/a>tspa  class="comment"> * new .e_shoff nor the new ElfXX_Shdr[].  [In order to remove the garbage,t/spa  
p 21t/a>tspa  class="comment"> * then use "ld -r" to create a new file that omits the garbage.]t/spa  
p 22t/a>tspa  class="comment"> */t/spa  
p 23pta 
p 24t/a>#include <sys/typvs.ht/a>>
p 25t/a>#include <sys/mman.ht/a>>
p 26t/a>#include <sys/stat.ht/a>>
p 27t/a>#include <getopt.ht/a>>
p 28t/a>#include <elf.ht/a>>
p 29t/a>#include <fcntl.ht/a>>
p 30t/a>#include <setjmp.ht/a>>
p 31t/a>#include <stdio.ht/a>>
p 32t/a>#include <stdlib.ht/a>>
p 33t/a>#include <string.ht/a>>
p 34t/a>#include <unistd.ht/a>>
p 35pta 
p 36t/a>static intpta href="+code=fd_map" class="sref">fd_mapt/a>;
 op ptspa  class="comment">/* File descriptor for file being modified. */t/spa  
p 37t/a>static intpta href="+code=mmap_failed" class="sref">mmap_failedt/a>;
tspa  class="comment">/* Boolea  flag. */t/spa  
p 38t/a>static void *ta href="+code=ehdr_curr" class="sref">ehdr_currt/a>;
tspa  class="comment">/* current ElfXX_Ehdr *  for resource clea up */t/spa  
p 39t/a>static charpta href="+code=gpfx" class="sref">gpfxt/a>;
 op p
tspa  class="comment">/* prefix for global symbol namv (sometimvs '_') */t/spa  
p 40t/a>static struct ta href="+code=stat" class="sref">statt/a> ta href="+code=sb" class="sref">sbt/a>;
 tspa  class="comment">/* Remember .st_size, etc. */t/spa  
p 41t/a>static ta href="+code=jmp_buf" class="sref">jmp_buft/a> ta href="+code=jmpenv" class="sref">jmpenvt/a>;
 tspa  class="comment">/* setjmp/longjmp per-file error escape */t/spa  
p 42t/a>static const charp*ta href="+code=altmcount" class="sref">altmcountt/a>;
 otspa  class="comment">/* alternate mcount symbol namv */t/spa  
p 43t/a>static intpta href="+code=warn_on_notrace_secn" class="sref">warn_on_notrace_secnt/a>;
tspa  class="comment">/* warn when secn>
  has mcount not being recorded */t/spa  
p 44pta 
p 45t/a>tspa  class="comment">/* setjmp() return ue="vs */t/spa  
p 46t/a>enum {
p 47t/a> 
 op p
ta href="+code=SJ_SETJMP" class="sref">SJ_SETJMPt/a> = 0, otspa  class="comment">/* hardwired first return */t/spa  
p 48t/a> 
 op p
ta href="+code=SJ_FAIL" class="sref">SJ_FAILt/a>,
p 49t/a> 
 op p
ta href="+code=SJ_SUCCEED" class="sref">SJ_SUCCEEDpta 
p 50t/a>};
p 51pta 
p 52t/a>tspa  class="comment">/* Per-file resource clea up when multiple files. */t/spa  
p 53t/a>static void
p 54t/a>ta href="+code=clea up" class="sref">clea upt/a>(void)
p 55t/a>{
p 56t/a> 
 op p
if (!ta href="+code=mmap_failed" class="sref">mmap_failedt/a>)
p 57t/a> 
 op p
 
 op p
ta href="+code=munmap" class="sref">munmapt/a>(ta href="+code=ehdr_curr" class="sref">ehdr_currt/a>, ta href="+code=sb" class="sref">sbt/a>.ta href="+code=st_size" class="sref">st_sizet/a>);
p 58t/a> 
 op p
else
p 59t/a> 
 op p
 
 op p
ta href="+code=free" class="sref">freet/a>(ta href="+code=ehdr_curr" class="sref">ehdr_currt/a>);
p 60t/a> 
 op p
ta href="+code=close" class="sref">closet/a>(ta href="+code=fd_map" class="sref">fd_mapt/a>);
p 61pta }
p 62pta 
p 63t/a>static void
ta href="+code=__attribute__" class="sref">__attribute__t/a>((ta href="+code=noreturn" class="sref">noreturnt/a>))
p 64t/a>ta href="+code=fail_file" class="sref">fail_filet/a>(void)
p 65t/a>{
p 66t/a> 
 op p
ta href="+code=clea up" class="sref">clea upt/a>();
p 67t/a> 
 op p
ta href="+code=longjmp" class="sref">longjmpt/a>(ta href="+code=jmpenv" class="sref">jmpenvt/a>, ta href="+code=SJ_FAIL" class="sref">SJ_FAILt/a>);
p 68pta }
p 69pta 
p 70t/a>static void
ta href="+code=__attribute__" class="sref">__attribute__t/a>((ta href="+code=noreturn" class="sref">noreturnt/a>))
p 71t/a>ta href="+code=succeed_file" class="sref">succeed_filet/a>(void)
p 72t/a>{
p 73t/a> 
 op p
ta href="+code=clea up" class="sref">clea upt/a>();
p 74t/a> 
 op p
ta href="+code=longjmp" class="sref">longjmpt/a>(ta href="+code=jmpenv" class="sref">jmpenvt/a>, ta href="+code=SJ_SUCCEED" class="sref">SJ_SUCCEEDpta );
p 75pta }
p 76pta 
p 77t/a>tspa  class="comment">/* ulseek, uread, ...:  Check return ue="v for errors. */t/spa  
p 78pta 
p 79t/a>static ta href="+code=off_n" class="sref">off_npta 
p 80t/a>ta href="+code=ulseek" class="sref">ulseekt/a>(intpconst ta href="+code=fd" class="sref">fdt/a>, ta href="+code=off_n" class="sref">off_npta pconst ta href="+code=offsen" class="sref">offsent/a>, intpconst ta href="+code=whence" class="sref">whencet/a>)
p 81t/a>{
p 82t/a> 
 op p
ta href="+code=off_n" class="sref">off_npta pconst ta href="+code=w" class="sref">wt/a> = ta href="+code=lseek" class="sref">lseekt/a>(ta href="+code=fd" class="sref">fdt/a>, ta href="+code=offsen" class="sref">offsent/a>, ta href="+code=whence" class="sref">whencet/a>);
p 83t/a> 
 op p
if (ta href="+code=w" class="sref">wt/a> == (ta href="+code=off_n" class="sref">off_npta )-1) {
p 84t/a> 
 op p
 
 op p
ta href="+code=perror" class="sref">perrort/a>(tspa  class="string">"lseek"t/spa  );
p 85t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p 86t/a> 
 op p
}
p 87t/a> 
 op p
return ta href="+code=w" class="sref">wt/a>;
p 88pta }
p 89pta 
p 90t/a>static ta href="+code=size_n" class="sref">size_npta 
p 91t/a>ta href="+code=uread" class="sref">ureadt/a>(intpconst ta href="+code=fd" class="sref">fdt/a>, void *const ta href="+code=buf" class="sref">buft/a>, ta href="+code=size_n" class="sref">size_npta pconst ta href="+code=count" class="sref">countt/a>)
p 92t/a>{
p 93t/a> 
 op p
ta href="+code=size_n" class="sref">size_npta pconst ta href="+code=n" class="sref">nt/a> = ta href="+code=read" class="sref">readt/a>(ta href="+code=fd" class="sref">fdt/a>, ta href="+code=buf" class="sref">buft/a>, ta href="+code=count" class="sref">countt/a>);
p 94t/a> 
 op p
if (ta href="+code=n" class="sref">nt/a> != ta href="+code=count" class="sref">countt/a>) {
p 95t/a> 
 op p
 
 op p
ta href="+code=perror" class="sref">perrort/a>(tspa  class="string">"read"t/spa  );
p 96t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p 97t/a> 
 op p
}
p 98t/a> 
 op p
return ta href="+code=n" class="sref">nt/a>;
p 99pta }
p100pta 
p101t/a>static ta href="+code=size_n" class="sref">size_npta 
p102t/a>ta href="+code=uwrite" class="sref">uwritet/a>(intpconst ta href="+code=fd" class="sref">fdt/a>, void const *const ta href="+code=buf" class="sref">buft/a>, ta href="+code=size_n" class="sref">size_npta pconst ta href="+code=count" class="sref">countt/a>)
p103t/a>{
p104t/a> 
 op p
ta href="+code=size_n" class="sref">size_npta pconst ta href="+code=n" class="sref">nt/a> = ta href="+code=write" class="sref">writet/a>(ta href="+code=fd" class="sref">fdt/a>, ta href="+code=buf" class="sref">buft/a>, ta href="+code=count" class="sref">countt/a>);
p105t/a> 
 op p
if (ta href="+code=n" class="sref">nt/a> != ta href="+code=count" class="sref">countt/a>) {
p106t/a> 
 op p
 
 op p
ta href="+code=perror" class="sref">perrort/a>(tspa  class="string">"write"t/spa  );
p107t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p108t/a> 
 op p
}
p109t/a> 
 op p
return ta href="+code=n" class="sref">nt/a>;
p1/opta }
p111pta 
p112t/a>static void *
p113t/a>ta href="+code=umalloc" class="sref">umalloct/a>(ta href="+code=size_n" class="sref">size_npta pta href="+code=size" class="sref">sizet/a>)
p114t/a>{
p115t/a> 
 op p
void *const ta href="+code=addr" class="sref">addrt/a> = ta href="+code=malloc" class="sref">malloct/a>(ta href="+code=size" class="sref">sizet/a>);
p116t/a> 
 op p
if (ta href="+code=addr" class="sref">addrt/a> == 0) {
p117t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"malloc failed: %zu bytes\n"t/spa  , ta href="+code=size" class="sref">sizet/a>);
p118t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p119t/a> 
 op p
}
p120t/a> 
 op p
return ta href="+code=addr" class="sref">addrt/a>;
p121pta }
p122pta 
p123t/a>static unsigned charpta href="+code=ideal_nop5_x86_64" class="sref">ideal_nop5_x86_64t/a>[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
p124t/a>static unsigned charpta href="+code=ideal_nop5_x86_32" class="sref">ideal_nop5_x86_32t/a>[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 };
p125t/a>static unsigned charp*ta href="+code=ideal_nop" class="sref">ideal_nopt/a>;
p126pta 
p127t/a>static charpta href="+code=rel_typv_nop" class="sref">rel_typv_nopt/a>;
p128pta 
p129t/a>static intp(*ta href="+code=makv_nop" class="sref">makv_nopt/a>)(void *ta href="+code=map" class="sref">mapt/a>, ta href="+code=size_n" class="sref">size_npta pconst ta href="+code=offsen" class="sref">offsent/a>);
p130pta 
p131t/a>static intpta href="+code=makv_nop_x86" class="sref">makv_nop_x86t/a>(void *ta href="+code=map" class="sref">mapt/a>, ta href="+code=size_n" class="sref">size_npta pconst ta href="+code=offsen" class="sref">offsent/a>)
p132t/a>{
p133t/a> 
 op p
ta href="+code=uint32_n" class="sref">uint32_nt/a> *ta href="+code=ptr" class="sref">ptrt/a>;
p134t/a> 
 op p
unsigned charp*ta href="+code=op" class="sref">opt/a>;
p135pta 
p136t/a> 
 op p
tspa  class="comment">/* Confirm we have 0xe8 0x0 0x0 0x0 0x0 */t/spa  
p137t/a> 
 op p
ta href="+code=ptr" class="sref">ptrt/a> = ta href="+code=map" class="sref">mapt/a> + ta href="+code=offsen" class="sref">offsent/a>;
p138t/a> 
 op p
if (*ta href="+code=ptr" class="sref">ptrt/a> != 0)
p139t/a> 
 op p
 
 op p
return -1;
p140pta 
p141t/a> 
 op p
ta href="+code=op" class="sref">opt/a> = ta href="+code=map" class="sref">mapt/a> + ta href="+code=offsen" class="sref">offsent/a> - 1;
p142t/a> 
 op p
if (*ta href="+code=op" class="sref">opt/a> != 0xe8)
p143t/a> 
 op p
 
 op p
return -1;
p144pta 
p145t/a> 
 op p
tspa  class="comment">/* convert to nop */t/spa  
p146t/a> 
 op p
ta href="+code=ulseek" class="sref">ulseekt/a>(ta href="+code=fd_map" class="sref">fd_mapt/a>, ta href="+code=offsen" class="sref">offsent/a> - 1, ta href="+code=SEEK_SET" class="sref">SEEK_SETt/a>);
p147t/a> 
 op p
ta href="+code=uwrite" class="sref">uwritet/a>(ta href="+code=fd_map" class="sref">fd_mapt/a>, ta href="+code=ideal_nop" class="sref">ideal_nopt/a>, 5);
p148t/a> 
 op p
return 0;
p149pta }
p150pta 
p151t/a>tspa  class="comment">/*t/spa  
p152t/a>tspa  class="comment"> * Get the whole file as a programming convenience in order to avoidt/spa  
p153t/a>tspa  class="comment"> * malloc+lseek+read+free of many pieces.  If successful, then mmapt/spa  
p154t/a>tspa  class="comment"> * avoids copying unused pieces;
else just read the whole file.t/spa  
p155t/a>tspa  class="comment"> * Open for both read and write; new info will be appended to the file.t/spa  
p156t/a>tspa  class="comment"> * Use MAP_PRIVATE so that a few changes to the in-memory ElfXX_Ehdrt/spa  
p157t/a>tspa  class="comment"> * do not propagate to the file until an explicit overwrite at the last.t/spa  
p158t/a>tspa  class="comment"> * This preserves most aspects of consistency (all except .st_size)t/spa  
p159t/a>tspa  class="comment"> * for simultaneous readers of the file while we are appending to it.t/spa  
p160t/a>tspa  class="comment"> * However, multiple writers still are bad.  We choose not to uset/spa  
p161t/a>tspa  class="comment"> * locking because it is expensive and the use case of kernel buildt/spa  
p162t/a>tspa  class="comment"> * makvs multiple writers unlikely.t/spa  
p163t/a>tspa  class="comment"> */t/spa  
p164t/a>static void *ta href="+code=mmap_file" class="sref">mmap_filet/a>(charpconst *ta href="+code=fnamv" class="sref">fnamvt/a>)
p165t/a>{
p166t/a> 
 op p
void *ta href="+code=addr" class="sref">addrt/a>;
p167t/a>
p168t/a> 
 op p
ta href="+code=fd_map" class="sref">fd_mapt/a> = ta href="+code=open" class="sref">opent/a>(ta href="+code=fnamv" class="sref">fnamvt/a>, ta href="+code=O_RDWR" class="sref">O_RDWRt/a>);
p169t/a> 
 op p
if (ta href="+code=fd_map" class="sref">fd_mapt/a> < 0 ||
ta href="+code=fstat" class="sref">fstatt/a>(ta href="+code=fd_map" class="sref">fd_mapt/a>, &ta href="+code=sb" class="sref">sbt/a>) < 0) {
p170t/a> 
 op p
 
 op p
ta href="+code=perror" class="sref">perrort/a>(ta href="+code=fnamv" class="sref">fnamvt/a>);
p171t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p172t/a> 
 op p
}
p173t/a> 
 op p
if (!ta href="+code=S_ISREG" class="sref">S_ISREGt/a>(ta href="+code=sb" class="sref">sbt/a>.ta href="+code=st_mode" class="sref">st_modet/a>)) {
p174t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"not a regular file: %s\n"t/spa  , ta href="+code=fnamv" class="sref">fnamvt/a>);
p175t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p176t/a> 
 op p
}
p177t/a> 
 op p
ta href="+code=addr" class="sref">addrt/a> = ta href="+code=mmap" class="sref">mmapt/a>(0, ta href="+code=sb" class="sref">sbt/a>.ta href="+code=st_size" class="sref">st_sizet/a>, ta href="+code=PROT_READ" class="sref">PROT_READt/a>|ta href="+code=PROT_WRITE" class="sref">PROT_WRITEt/a>, ta href="+code=MAP_PRIVATE" class="sref">MAP_PRIVATEt/a>,
p178t/a> 
 op p
 
 op p
p p
ta href="+code=fd_map" class="sref">fd_mapt/a>, 0);
p179t/a> 
 op p
ta href="+code=mmap_failed" class="sref">mmap_failedt/a> = 0;
p180t/a> 
 op p
if (ta href="+code=addr" class="sref">addrt/a> == ta href="+code=MAP_FAILED" class="sref">MAP_FAILEDt/a>) {
p181t/a> 
 op p
 
 op p
ta href="+code=mmap_failed" class="sref">mmap_failedt/a> = 1;
p182t/a> 
 op p
 
 op p
ta href="+code=addr" class="sref">addrt/a> = ta href="+code=umalloc" class="sref">umalloct/a>(ta href="+code=sb" class="sref">sbt/a>.ta href="+code=st_size" class="sref">st_sizet/a>);
p183t/a> 
 op p
 
 op p
ta href="+code=uread" class="sref">ureadt/a>(ta href="+code=fd_map" class="sref">fd_mapt/a>, ta href="+code=addr" class="sref">addrt/a>, ta href="+code=sb" class="sref">sbt/a>.ta href="+code=st_size" class="sref">st_sizet/a>);
p184t/a> 
 op p
}
p185t/a> 
 op p
return ta href="+code=addr" class="sref">addrt/a>;
p186t/a>}
p187t/a>
p188t/a>tspa  class="comment">/* w8rev, w8nat, ...: Handle endianness. */t/spa  
p189pta 
p190t/a>static ta href="+code=uint64_n" class="sref">uint64_nt/a> ta href="+code=w8rev" class="sref">w8revt/a>(ta href="+code=uint64_n" class="sref">uint64_nt/a> const ta href="+code=x" class="sref">xt/a>)
p191t/a>{
p192t/a> 
 op p
return   ((0xff & (ta href="+code=x" class="sref">xt/a> >> (0 * 8))) << (7 * 8))
p193t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (1 * 8))) << (6 * 8))
p194t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (2 * 8))) << (5 * 8))
p195t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (3 * 8))) << (4 * 8))
p196t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (4 * 8))) << (3 * 8))
p197t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (5 * 8))) << (2 * 8))
p198t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (6 * 8))) << (1 * 8))
p199t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (7 * 8))) << (0 * 8));
p20opta }
p201pta 
p202t/a>static ta href="+code=uint32_n" class="sref">uint32_nt/a> ta href="+code=w4rev" class="sref">w4revt/a>(ta href="+code=uint32_n" class="sref">uint32_nt/a> const ta href="+code=x" class="sref">xt/a>)
p203t/a>{
p204t/a> 
 op p
return   ((0xff & (ta href="+code=x" class="sref">xt/a> >> (0 * 8))) << (3 * 8))
p205t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (1 * 8))) << (2 * 8))
p206t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (2 * 8))) << (1 * 8))
p207t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (3 * 8))) << (0 * 8));
p208pta }
p209pta 
p210t/a>static ta href="+code=uint32_n" class="sref">uint32_nt/a> ta href="+code=w2rev" class="sref">w2revt/a>(ta href="+code=uint16_n" class="sref">uint16_nt/a> const ta href="+code=x" class="sref">xt/a>)
p211t/a>{
p212t/a> 
 op p
return   ((0xff & (ta href="+code=x" class="sref">xt/a> >> (0 * 8))) << (1 * 8))
p213t/a> 
 op p
 
 op p| ((0xff & (ta href="+code=x" class="sref">xt/a> >> (1 * 8))) << (0 * 8));
p214t/a>}
p215pta 
p216t/a>static ta href="+code=uint64_n" class="sref">uint64_nt/a> ta href="+code=w8nat" class="sref">w8natt/a>(ta href="+code=uint64_n" class="sref">uint64_nt/a> const ta href="+code=x" class="sref">xt/a>)
p217t/a>{
p218t/a> 
 op p
return ta href="+code=x" class="sref">xt/a>;
p219pta }
p220pta 
p221t/a>static ta href="+code=uint32_n" class="sref">uint32_nt/a> ta href="+code=w4nat" class="sref">w4natt/a>(ta href="+code=uint32_n" class="sref">uint32_nt/a> const ta href="+code=x" class="sref">xt/a>)
p222t/a>{
p223t/a> 
 op p
return ta href="+code=x" class="sref">xt/a>;
p224t/a>}
p225pta 
p226t/a>static ta href="+code=uint32_n" class="sref">uint32_nt/a> ta href="+code=w2nat" class="sref">w2natt/a>(ta href="+code=uint16_n" class="sref">uint16_nt/a> const ta href="+code=x" class="sref">xt/a>)
p227t/a>{
p228t/a> 
 op p
return ta href="+code=x" class="sref">xt/a>;
p229pta }
p230pta 
p231t/a>static ta href="+code=uint64_n" class="sref">uint64_nt/a> (*ta href="+code=w8" class="sref">w8t/a>)(ta href="+code=uint64_n" class="sref">uint64_nt/a>);
p232t/a>static ta href="+code=uint32_n" class="sref">uint32_nt/a> (*ta href="+code=w" class="sref">wt/a>)(ta href="+code=uint32_n" class="sref">uint32_nt/a>);
p233t/a>static ta href="+code=uint32_n" class="sref">uint32_nt/a> (*ta href="+code=w2" class="sref">w2t/a>)(ta href="+code=uint16_n" class="sref">uint16_nt/a>);
p234pta 
p235t/a>tspa  class="comment">/* Namvs of the secn>
 s that could contai  calls to mcount. */t/spa  
p236t/a>static int
p237t/a>ta href="+code=is_mcounted_secn>
 _namv" class="sref">is_mcounted_secn>
 _namvt/a>(charpconst *const ta href="+code=txtnamv" class="sref">txtnamvt/a>)
p238t/a>{
p239t/a> 
 op p
return ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".text"t/spa  ,           ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0 ||
p240t/a> 
 op p
 
 op p
ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".ref.text"t/spa  ,      ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0 ||
p241t/a> 
 op p
 
 op p
ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".sched.text"t/spa  ,    ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0 ||
p242t/a> 
 op p
 
 op p
ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".spinlock.text"t/spa  , ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0 ||
p243t/a> 
 op p
 
 op p
ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".irqentry.text"t/spa  , ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0 ||
p244t/a> 
 op p
 
 op p
ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".kprobes.text"t/spa  , ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0 ||
p245t/a> 
 op p
 
 op p
ta href="+code=strcmp" class="sref">strcmpt/a>(tspa  class="string">".text.unlikely"t/spa  , ta href="+code=txtnamv" class="sref">txtnamvt/a>) == 0;
p246t/a>}
p247t/a>
p248t/a>tspa  class="comment">/* 32 bit and 64 bit are very similar */t/spa  
p249pta #include "ta href="scripts/recordmcount.h" class="fref">recordmcount.hpta "
p250pta #define ta href="+code=RECORD_MCOUNT_64" class="sref">RECORD_MCOUNT_64t/a>
p251t/a>#include "ta href="scripts/recordmcount.h" class="fref">recordmcount.hpta "
p252pta 
p253t/a>tspa  class="comment">/* 64-bit EM_MIPS has weird ELF64_Rela.r_info.t/spa  
p254t/a>tspa  class="comment"> * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdft/spa  
p255t/a>tspa  class="comment"> * We interpret Table 29 Relocan>
  Operan>
  (Elf64_Rel, Elf64_Rela) [p.40]t/spa  
p256t/a>tspa  class="comment"> * to imply the order of the members; the spec dovs not say so.t/spa  
p257t/a>tspa  class="comment"> *      typvdef
unsigned charpElf64_Byte;t/spa  
p258t/a>tspa  class="comment"> * fails 
  MIPS64 because their <elf.h> already has it!t/spa  
p259t/a>tspa  class="comment"> */t/spa  
p260pta 
p261t/a>typvdef
ta href="+code=uint8_n" class="sref">uint8_nt/a> ta href="+code=myElf64_Byte" class="sref">myElf64_Bytet/a>; p
 
 op p
tspa  class="comment">/* Typv for a 8-bit quantity.  */t/spa  
p262pta 
p263t/a>un>
  ta href="+code=mips_r_info" class="sref">mips_r_infot/a> {
p264t/a> 
 op p
ta href="+code=Elf64_Xword" class="sref">Elf64_Xwordt/a> ta href="+code=r_info" class="sref">r_infot/a>;
p265t/a> 
 op p
struct {
p266t/a> 
 op p
 
 op p
ta href="+code=Elf64_Word" class="sref">Elf64_Wordt/a> ta href="+code=r_sym" class="sref">r_symt/a>; p
 
 op p
p p
tspa  class="comment">/* Symbol index.  */t/spa  
p267t/a> 
 op p
 
 op p
ta href="+code=myElf64_Byte" class="sref">myElf64_Bytet/a> ta href="+code=r_ssym" class="sref">r_ssymt/a>; p
 
 op p
ptspa  class="comment">/* Special symbol.  */t/spa  
p268t/a> 
 op p
 
 op p
ta href="+code=myElf64_Byte" class="sref">myElf64_Bytet/a> ta href="+code=r_typv3" class="sref">r_typv3t/a>; p
 
 op p
tspa  class="comment">/* Third relocan>
 .  */t/spa  
p269t/a> 
 op p
 
 op p
ta href="+code=myElf64_Byte" class="sref">myElf64_Bytet/a> ta href="+code=r_typv2" class="sref">r_typv2t/a>; p
 
 op p
tspa  class="comment">/* Second relocan>
 .  */t/spa  
p270t/a> 
 op p
 
 op p
ta href="+code=myElf64_Byte" class="sref">myElf64_Bytet/a> ta href="+code=r_typv" class="sref">r_typvt/a>; p
 
 op p
ptspa  class="comment">/* First relocan>
 .  */t/spa  
p271t/a> 
 op p
} ta href="+code=r_mips" class="sref">r_mipst/a>;
p272t/a>};
p273t/a>
p274t/a>static ta href="+code=uint64_n" class="sref">uint64_nt/a> ta href="+code=MIPS64_r_sym" class="sref">MIPS64_r_symt/a>(ta href="+code=Elf64_Rel" class="sref">Elf64_Relt/a> const *ta href="+code=rp" class="sref">rpt/a>)
p275t/a>{
p276t/a> 
 op p
return ta href="+code=w" class="sref">wt/a>(((un>
  ta href="+code=mips_r_info" class="sref">mips_r_infot/a>){ .ta href="+code=r_info" class="sref">r_infot/a> = ta href="+code=rp" class="sref">rpt/a>->ta href="+code=r_info" class="sref">r_infot/a> }).ta href="+code=r_mips" class="sref">r_mipst/a>.ta href="+code=r_sym" class="sref">r_symt/a>);
p277t/a>}
p278pta 
p279t/a>static void ta href="+code=MIPS64_r_info" class="sref">MIPS64_r_infot/a>(ta href="+code=Elf64_Rel" class="sref">Elf64_Relt/a> *const ta href="+code=rp" class="sref">rpt/a>,
unsigned ta href="+code=sym" class="sref">symt/a>,
unsigned ta href="+code=typv" class="sref">typvt/a>)
p280t/a>{
p281t/a> 
 op p
ta href="+code=rp" class="sref">rpt/a>->ta href="+code=r_info" class="sref">r_infot/a> = ((un>
  ta href="+code=mips_r_info" class="sref">mips_r_infot/a>){
p282t/a> 
 op p
 
 op p
.ta href="+code=r_mips" class="sref">r_mipst/a> = { .ta href="+code=r_sym" class="sref">r_symt/a> = ta href="+code=w" class="sref">wt/a>(ta href="+code=sym" class="sref">symt/a>), .ta href="+code=r_typv" class="sref">r_typvt/a> = ta href="+code=typv" class="sref">typvt/a>
}
p283t/a> 
 op p
}).ta href="+code=r_info" class="sref">r_infot/a>;
p284t/a>}
p285pta 
p286t/a>static void
p287t/a>ta href="+code=do_file" class="sref">do_filet/a>(charpconst *const ta href="+code=fnamv" class="sref">fnamvt/a>)
p288t/a>{
p289t/a> 
 op p
ta href="+code=Elf32_Ehdr" class="sref">Elf32_Ehdrt/a> *const ta href="+code=ehdr" class="sref">ehdrt/a> = ta href="+code=mmap_file" class="sref">mmap_filet/a>(ta href="+code=fnamv" class="sref">fnamvt/a>);
p290t/a> 
 op p
unsigned intpta href="+code=reltypv" class="sref">reltypvt/a> = 0;
p291pta 
p292t/a> 
 op p
ta href="+code=ehdr_curr" class="sref">ehdr_currt/a> = ta href="+code=ehdr" class="sref">ehdrt/a>;
p293t/a> 
 op p
ta href="+code=w" class="sref">wt/a> = ta href="+code=w4nat" class="sref">w4natt/a>;
p294t/a> 
 op p
ta href="+code=w2" class="sref">w2t/a> = ta href="+code=w2nat" class="sref">w2natt/a>;
p295t/a> 
 op p
ta href="+code=w8" class="sref">w8t/a> = ta href="+code=w8nat" class="sref">w8natt/a>;
p296t/a> 
 op p
switch (ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ident" class="sref">e_identt/a>[ta href="+code=EI_DATA" class="sref">EI_DATAt/a>]) {
p297t/a> 
 op p
 
 op p static unsigned intpconst ta href="+code=endian" class="sref">endiant/a> = 1;
p298t/a> 
 op p
default:
p299t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"unrecognized ELF data encoding %d: %s\n"t/spa  ,
p300t/a> 
 op p
 
 op p
 
 op p
ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ident" class="sref">e_identt/a>[ta href="+code=EI_DATA" class="sref">EI_DATAt/a>], ta href="+code=fnamv" class="sref">fnamvt/a>);
p301t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p302t/a> 
 op p
 
 op p
break;
p303t/a> 
 op p
case ta href="+code=ELFDATA2LSB" class="sref">ELFDATA2LSBt/a>:
p304t/a> 
 op p
 
 op p
if (*(unsigned charpconst *)&ta href="+code=endian" class="sref">endiant/a> != 1) {
p305t/a> 
 op p
 
 op p
 
 op p
tspa  class="comment">/* main() is big endian, file.o is little endian. */t/spa  
p306t/a> 
 op p
 
 op p
 
 op p
ta href="+code=w" class="sref">wt/a> = ta href="+code=w4rev" class="sref">w4revt/a>;
p307t/a> 
 op p
 
 op p
 
 op p
ta href="+code=w2" class="sref">w2t/a> = ta href="+code=w2rev" class="sref">w2revt/a>;
p308t/a> 
 op p
 
 op p
p p
p p
ta href="+code=w8" class="sref">w8t/a> = ta href="+code=w8rev" class="sref">w8revt/a>;
p309t/a> 
 op p
 
 op p
}
p310t/a> 
 op p
 
 op p
break;
p311t/a> 
 op p
case ta href="+code=ELFDATA2MSB" class="sref">ELFDATA2MSBt/a>:
p312t/a> 
 op p
 
 op p
if (*(unsigned charpconst *)&ta href="+code=endian" class="sref">endiant/a> != 0) {
p313t/a> 
 op p
 
 op p
p p
p p
tspa  class="comment">/* main() is little endian, file.o is big endian. */t/spa  
p314t/a> 
 op p
 
 op p
p p
p p
ta href="+code=w" class="sref">wt/a> = ta href="+code=w4rev" class="sref">w4revt/a>;
p315t/a> 
 op p
 
 op p
 
 op p
ta href="+code=w2" class="sref">w2t/a> = ta href="+code=w2rev" class="sref">w2revt/a>;
p316t/a> 
 op p
 
 op p
 
 op p
ta href="+code=w8" class="sref">w8t/a> = ta href="+code=w8rev" class="sref">w8revt/a>;
p317t/a> 
 op p
 
 op p
}
p318t/a> 
 op p
 
 op p
break;
p319t/a> 
 op p
}p
tspa  class="comment">/* end
switch */t/spa  
p320t/a> 
 op p
if (ta href="+code=memcmp" class="sref">memcmpt/a>(ta href="+code=ELFMAG" class="sref">ELFMAGt/a>, ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ident" class="sref">e_identt/a>, ta href="+code=SELFMAG" class="sref">SELFMAGt/a>) != 0
p321t/a> 
 op p
||p
ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_typv" class="sref">e_typvt/a>) != ta href="+code=ET_REL" class="sref">ET_RELpta 
p322t/a> 
 op p
||p
ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ident" class="sref">e_identt/a>[ta href="+code=EI_VERSION" class="sref">EI_VERSIONt/a>] != ta href="+code=EV_CURRENT" class="sref">EV_CURRENTt/a>) {
p323t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"unrecognized ET_REL file %s\n"t/spa  , ta href="+code=fnamv" class="sref">fnamvt/a>);
p324t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p325t/a> 
 op p
}
p326t/a>
p327t/a> 
 op p
ta href="+code=gpfx" class="sref">gpfxt/a> = 0;
p328t/a> 
 op p
switch (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_machine" class="sref">e_machinet/a>)) {
p329t/a> 
 op p
default:
p330t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"unrecognized e_machine %d %s\n"t/spa  ,
p331t/a> 
 op p
 
 op p
 
 op p
ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_machine" class="sref">e_machinet/a>), ta href="+code=fnamv" class="sref">fnamvt/a>);
p332t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p333t/a> 
 op p
 
 op p
break;
p334t/a> 
 op p
case ta href="+code=EM_386" class="sref">EM_386t/a>:
p335t/a> 
 op p
 
 op p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_386_32" class="sref">R_386_32t/a>;
p336t/a> 
 op p
 
 op p
ta href="+code=makv_nop" class="sref">makv_nopt/a> = ta href="+code=makv_nop_x86" class="sref">makv_nop_x86t/a>;
p337t/a> 
 op p
 
 op p
ta href="+code=ideal_nop" class="sref">ideal_nopt/a> = ta href="+code=ideal_nop5_x86_32" class="sref">ideal_nop5_x86_32t/a>;
p338t/a> 
 op p
 
 op p
ta href="+code=mcount_adjust_32" class="sref">mcount_adjust_32t/a> = -1;
p339t/a> 
 op p
 
 op p
break;
p340t/a> 
 op p
case ta href="+code=EM_ARM" class="sref">EM_ARMt/a>:op p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_ARM_ABS32" class="sref">R_ARM_ABS32t/a>;
p341t/a> 
 op p
 
 op p

 
 op p
ta href="+code=altmcount" class="sref">altmcountt/a> = tspa  class="string">"__gnu_mcount_nc"t/spa  ;
p342t/a> 
 op p
 
 op p

 
 op p
break;
p343t/a> 
 op p
case ta href="+code=EM_IA_64" class="sref">EM_IA_64t/a>:op ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_IA64_IMM64" class="sref">R_IA64_IMM64t/a>;op ta href="+code=gpfx" class="sref">gpfxt/a> = tspa  class="string">'_'t/spa  ;
break;
p344t/a> 
 op p
case ta href="+code=EM_MIPS" class="sref">EM_MIPSt/a>:op ptspa  class="comment">/* reltypv: e_classop p*/t/spa   ta href="+code=gpfx" class="sref">gpfxt/a> = tspa  class="string">'_'t/spa  ;
break;
p345t/a> 
 op p
case ta href="+code=EM_PPC" class="sref">EM_PPCt/a>:op p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_PPC_ADDR32" class="sref">R_PPC_ADDR32t/a>;op ta href="+code=gpfx" class="sref">gpfxt/a> = tspa  class="string">'_'t/spa  ;
break;
p346t/a> 
 op p
case ta href="+code=EM_PPC64" class="sref">EM_PPC64t/a>:op ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_PPC64_ADDR64" class="sref">R_PPC64_ADDR64t/a>;ota href="+code=gpfx" class="sref">gpfxt/a> = tspa  class="string">'_'t/spa  ;
break;
p347t/a> 
 op p
case ta href="+code=EM_S390" class="sref">EM_S390t/a>:op ptspa  class="comment">/* reltypv: e_classop p*/t/spa   ta href="+code=gpfx" class="sref">gpfxt/a> = tspa  class="string">'_'t/spa  ;
break;
p348t/a> 
 op p
case ta href="+code=EM_SH" class="sref">EM_SHt/a>:op p
 ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_SH_DIR32" class="sref">R_SH_DIR32t/a>;op op p

 
 op p
break;
p349t/a> 
 op p
case ta href="+code=EM_SPARCV9" class="sref">EM_SPARCV9t/a>:ota href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_SPARC_64" class="sref">R_SPARC_64t/a>;op opta href="+code=gpfx" class="sref">gpfxt/a> = tspa  class="string">'_'t/spa  ;
break;
p350t/a> 
 op p
case ta href="+code=EM_X86_64" class="sref">EM_X86_64t/a>:
p351t/a> 
 op p
 
 op p
ta href="+code=makv_nop" class="sref">makv_nopt/a> = ta href="+code=makv_nop_x86" class="sref">makv_nop_x86t/a>;
p352t/a> 
 op p
 
 op p
ta href="+code=ideal_nop" class="sref">ideal_nopt/a> = ta href="+code=ideal_nop5_x86_64" class="sref">ideal_nop5_x86_64t/a>;
p353t/a> 
 op p
 
 op p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_X86_64_64" class="sref">R_X86_64_64t/a>;
p354t/a> 
 op p
 
 op p
ta href="+code=mcount_adjust_64" class="sref">mcount_adjust_64t/a> = -1;
p355t/a> 
 op p
 
 op p
break;
p356t/a> 
 op p
}p
tspa  class="comment">/* end
switch */t/spa  
p357t/a>
p358t/a> 
 op p
switch (ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ident" class="sref">e_identt/a>[ta href="+code=EI_CLASS" class="sref">EI_CLASSt/a>]) {
p359t/a> 
 op p
default:
p360t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"unrecognized ELF classo%d %s\n"t/spa  ,
p361t/a> 
 op p
 
 op p
 
 op p
ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ident" class="sref">e_identt/a>[ta href="+code=EI_CLASS" class="sref">EI_CLASSt/a>], ta href="+code=fnamv" class="sref">fnamvt/a>);
p362t/a> 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p363t/a> 
 op p
 
 op p
break;
p364t/a> 
 op p
case ta href="+code=ELFCLASS32" class="sref">ELFCLASS32t/a>:
p365t/a> 
 op p
 
 op p
if (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_ehsize" class="sref">e_ehsizet/a>) != sizeof(ta href="+code=Elf32_Ehdr" class="sref">Elf32_Ehdrt/a>)
p366t/a> 
 op p
 
 op p
||p
ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_shentsize" class="sref">e_shentsizet/a>) != sizeof(ta href="+code=Elf32_Shdr" class="sref">Elf32_Shdrt/a>)) {
p367t/a> 
 op p
 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>,
p368t/a> 
 op p
 
 op p
 
 op p
 
 op p
tspa  class="string">"unrecognized ET_REL file: %s\n"t/spa  , ta href="+code=fnamv" class="sref">fnamvt/a>);
p369t/a> 
 op p
 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p370t/a> 
 op p
 
 op p
}
p371t/a> 
 op p
 
 op p
if (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_machine" class="sref">e_machinet/a>) == ta href="+code=EM_S390" class="sref">EM_S390t/a>) {
p372t/a> 
 op p
 
 op p

 
 op pta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_390_32" class="sref">R_390_32t/a>;
p373t/a> 
 op p
 
 op p
p p
p p
ta href="+code=mcount_adjust_32" class="sref">mcount_adjust_32t/a> = -4;
p374t/a> 
 op p
 
 op p
}
p375t/a> 
 op p
 
 op p
if (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>->ta href="+code=e_machine" class="sref">e_machinet/a>) == ta href="+code=EM_MIPS" class="sref">EM_MIPSt/a>) {
p376t/a> 
 op p
 
 op p
 
 op p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_MIPS_32" class="sref">R_MIPS_32t/a>;
p377t/a> 
 op p
 
 op p
 
 op p
ta href="+code=is_fakv_mcount32" class="sref">is_fakv_mcount32t/a> = ta href="+code=MIPS32_is_fakv_mcount" class="sref">MIPS32_is_fakv_mcountt/a>;
p378t/a> 
 op p
 
 op p
}
p379t/a> 
 op p
 
 op p
ta href="+code=do32" class="sref">do32t/a>(ta href="+code=ehdr" class="sref">ehdrt/a>, ta href="+code=fnamv" class="sref">fnamvt/a>, ta href="+code=reltypv" class="sref">reltypvt/a>);
p380t/a> 
 op p
 
 op p
break;
p381t/a> 
 op p
case ta href="+code=ELFCLASS64" class="sref">ELFCLASS64t/a>:o{
p382t/a> 
 op p
 
 op p
ta href="+code=Elf64_Ehdr" class="sref">Elf64_Ehdrt/a> *const ta href="+code=ghdr" class="sref">ghdrt/a> = (ta href="+code=Elf64_Ehdr" class="sref">Elf64_Ehdrt/a> *)ta href="+code=ehdr" class="sref">ehdrt/a>;
p383t/a> 
 op p
 
 op p
if (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ghdr" class="sref">ghdrt/a>->ta href="+code=e_ehsize" class="sref">e_ehsizet/a>) != sizeof(ta href="+code=Elf64_Ehdr" class="sref">Elf64_Ehdrt/a>)
p384t/a> 
 op p
 
 op p
||p
ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ghdr" class="sref">ghdrt/a>->ta href="+code=e_shentsize" class="sref">e_shentsizet/a>) != sizeof(ta href="+code=Elf64_Shdr" class="sref">Elf64_Shdrt/a>)) {
p385t/a> 
 op p
 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>,
p386t/a> 
 op p
 
 op p
 
 op p
 
 op p
tspa  class="string">"unrecognized ET_REL file: %s\n"t/spa  , ta href="+code=fnamv" class="sref">fnamvt/a>);
p387t/a> 
 op p
 
 op p
 
 op p
ta href="+code=fail_file" class="sref">fail_filet/a>();
p388t/a> 
 op p
 
 op p
}
p389t/a> 
 op p
 
 op p
if (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ghdr" class="sref">ghdrt/a>->ta href="+code=e_machine" class="sref">e_machinet/a>) == ta href="+code=EM_S390" class="sref">EM_S390t/a>) {
p390t/a> 
 op p
 
 op p
 
 op p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_390_64" class="sref">R_390_64t/a>;
p391t/a> 
 op p
 
 op p
 
 op p
ta href="+code=mcount_adjust_64" class="sref">mcount_adjust_64t/a> = -8;
p392t/a> 
 op p
 
 op p
}
p393t/a> 
 op p
 
 op p
if (ta href="+code=w2" class="sref">w2t/a>(ta href="+code=ghdr" class="sref">ghdrt/a>->ta href="+code=e_machine" class="sref">e_machinet/a>) == ta href="+code=EM_MIPS" class="sref">EM_MIPSt/a>) {
p394t/a> 
 op p
 
 op p
p p
p p
ta href="+code=reltypv" class="sref">reltypvt/a> = ta href="+code=R_MIPS_64" class="sref">R_MIPS_64t/a>;
p395t/a> 
 op p
 
 op p
 
 op p
ta href="+code=Elf64_r_sym" class="sref">Elf64_r_symt/a> = ta href="+code=MIPS64_r_sym" class="sref">MIPS64_r_symt/a>;
p396t/a> 
 op p
 
 op p
 
 op p
ta href="+code=Elf64_r_info" class="sref">Elf64_r_infot/a> = ta href="+code=MIPS64_r_info" class="sref">MIPS64_r_infot/a>;
p397t/a> 
 op p
 
 op p  
 op p
ta href="+code=is_fakv_mcount64" class="sref">is_fakv_mcount64t/a> = ta href="+code=MIPS64_is_fakv_mcount" class="sref">MIPS64_is_fakv_mcountt/a>;
p398t/a> 
 op p
 
 op p
}
p399t/a> 
 op p
 
 op p
ta href="+code=do64" class="sref">do64t/a>(ta href="+code=ghdr" class="sref">ghdrt/a>, ta href="+code=fnamv" class="sref">fnamvt/a>, ta href="+code=reltypv" class="sref">reltypvt/a>);
p400t/a> 
 op p
 
 op p
break;
p401t/a> 
 op p
}
p402t/a> 
 op p
}p
tspa  class="comment">/* end
switch */t/spa  
p403t/a>
p404t/a> 
 op p
ta href="+code=cleanup" class="sref">cleanupt/a>();
p405t/a>}
p406t/a>
p407t/a>int
p408t/a>ta href="+code=main" class="sref">maint/a>(intpta href="+code=argc" class="sref">argct/a>, charp*ta href="+code=argv" class="sref">argvt/a>[])
p409t/a>{
p410t/a> 
 op p
const charpta href="+code=ftracv" class="sref">ftracvt/a>[] = tspa  class="string">"/ftracv.o"t/spa  ;
p411t/a> 
 op p
intpta href="+code=ftracv_size" class="sref">ftracv_sizet/a> = sizeof(ta href="+code=ftracv" class="sref">ftracvt/a>) - 1;
p412t/a> 
 op p
intpta href="+code=n_error" class="sref">n_errort/a> = 0;p
tspa  class="comment">/* gcc-4.3.0 false positive
complaintp*/t/spa  
p413t/a> 
 op p
intpta href="+code=c" class="sref">ct/a>;
p414t/a> 
 op p
intpta href="+code=i" class="sref">it/a>;
p415pta 
p416t/a> 
 op p
while ((ta href="+code=c" class="sref">ct/a> = ta href="+code=getopt" class="sref">getoptt/a>(ta href="+code=argc" class="sref">argct/a>, ta href="+code=argv" class="sref">argvt/a>, tspa  class="string">"w"t/spa  )) >= 0) {
p417t/a> 
 op p
 
 op p
switch (ta href="+code=c" class="sref">ct/a>) {
p418t/a> 
 op p
 
 op p
case tspa  class="string">'w't/spa  :
p419t/a> 
 op p
 
 op p
 
 op p
ta href="+code=warn_on_notracv_sect" class="sref">warn_on_notracv_sectt/a> = 1;
p420t/a> 
 op p
 
 op p
 
 op p
break;
p421t/a> 
 op p
 
 op p
default:
p422t/a> 
 op p
 
 op p

 
 op pta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"usage: recordmcount [-w] file.o...\n"t/spa  );
p423t/a> 
 op p
 
 op p








return 0;
p424t/a> 
 op p
 
 op p
}
p425t/a> 
 op p
}
p426t/a>
p427t/a> 
 op p
if ((ta href="+code=argc" class="sref">argct/a> - ta href="+code=optind" class="sref">optindt/a>) < 1) {
p428t/a> 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"usage: recordmcount [-w] file.o...\n"t/spa  );
p429t/a> 
 op p
 
 op p
return 0;
p430t/a> 
 op p
}
p431pta 
p432t/a> 
 op p
tspa  class="comment">/* Process each file in turn, allowing deep failure. */t/spa  
p433t/a> 
 op p
for (ta href="+code=i" class="sref">it/a> = ta href="+code=optind" class="sref">optindt/a>;ota href="+code=i" class="sref">it/a> < ta href="+code=argc" class="sref">argct/a>;ota href="+code=i" class="sref">it/a>++) {
p434t/a> 
 op p
 
 op p
charp*ta href="+code=file" class="sref">filet/a> = ta href="+code=argv" class="sref">argvt/a>[ta href="+code=i" class="sref">it/a>];
p435t/a> 
 op p
 
 op p
intpconst ta href="+code=sjval" class="sref">sjvalt/a> = ta href="+code=setjmp" class="sref">setjmpt/a>(ta href="+code=jmpenv" class="sref">jmpenvt/a>);
p436t/a> 
 op p
 
 op p
intpta href="+code=len" class="sref">lent/a>;
p437t/a>
p438t/a> 
 op p
 
 op p
tspa  class="comment">/*t/spa  
p439t/a>tspa  class="comment"> 
 op p
 
 op p
 * The file kernel/tracv/ftracv.o
references the mcountt/spa  
p440t/a>tspa  class="comment"> 
 op p
 
 op p
 * funcn>
  but does not
call it. Since ftracv.o
shouldt/spa  
p441t/a>tspa  class="comment"> 
 op p
 
 op p
 * not
be tracvd anyway, we just skip it.t/spa  
p442t/a>tspa  class="comment"> 
 op p
 
 op p
 */t/spa  
p443t/a> 
 op p
 
 op p
ta href="+code=len" class="sref">lent/a> = ta href="+code=strlen" class="sref">strlent/a>(ta href="+code=file" class="sref">filet/a>);
p444t/a> 
 op p
 
 op p
if (ta href="+code=len" class="sref">lent/a> >= ta href="+code=ftracv_size" class="sref">ftracv_sizet/a> &&
p445t/a> 
 op p
 
 op p
 
 ota href="+code=strcmp" class="sref">strcmpt/a>(ta href="+code=file" class="sref">filet/a> + (ta href="+code=len" class="sref">lent/a> - ta href="+code=ftracv_size" class="sref">ftracv_sizet/a>), ta href="+code=ftracv" class="sref">ftracvt/a>) == 0)
p446t/a> 
 op p
 
 op p
 
 op p
continue;
p447t/a>
p448t/a> 
 op p
 
 op p
switch (ta href="+code=sjval" class="sref">sjvalt/a>) {
p449t/a> 
 op p
 
 op p
default:
p450t/a> 
 op p
 
 op p
 
 op p
ta href="+code=fprintf" class="sref">fprintft/a>(ta href="+code=stderr" class="sref">stderrt/a>, tspa  class="string">"internal error: %s\n"t/spa  , ta href="+code=file" class="sref">filet/a>);
p451t/a> 
 op p
 
 op p
 
 op p
ta href="+code=exit" class="sref">exitt/a>(1);
p452t/a> 
 op p
 
 op p








break;
p453t/a> 
 op p
 
 op p
case ta href="+code=SJ_SETJMP" class="sref">SJ_SETJMPt/a>:op ptspa  class="comment">/* normal sequence */t/spa  
p454t/a> 
 op p
 
 op p
 
 op p
tspa  class="comment">/* Avoid problems
if early cleanup() */t/spa  
p455t/a> 
 op p
 
 op p
 
 op p
ta href="+code=fd_map" class="sref">fd_mapt/a> = -1;
p456t/a> 
 op p
 
 op p
 
 op p
ta href="+code=ehdr_curr" class="sref">ehdr_currt/a> = ta href="+code=NULL" class="sref">NULLt/a>;
p457t/a> 
 op p
 
 op p  
 op p
ta href="+code=mmap_failed" class="sref">mmap_failedt/a> = 1;
p458t/a> 
 op p
 
 op p
p p
p p
ta href="+code=do_file" class="sref">do_filet/a>(ta href="+code=file" class="sref">filet/a>);
p459t/a> 
 op p
 
 op p
 
 op p
break;
p460t/a> 
 op p
 
 op p
case ta href="+code=SJ_FAIL" class="sref">SJ_FAILt/a>:op ptspa  class="comment">/* error in do_file or below */t/spa  
p461t/a> 
 op p
 
 op p
 
 op p
++ta href="+code=n_error" class="sref">n_errort/a>;
p462t/a> 
 op p
 
 op p
 
 op p
break;
p463t/a> 
 op p
 
 op p
case ta href="+code=SJ_SUCCEED" class="sref">SJ_SUCCEEDt/a>:op ptspa  class="comment">/* premature success */t/spa  
p464t/a> 
 op p
 
 op p
 
 op p
tspa  class="comment">/* do nothing */t/spa  
p465t/a> 
 op p
 
 op p
 
 op p
break;
p466t/a> 
 op p
 
 op p
}p
tspa  class="comment">/* end
switch */t/spa  
p467t/a> 
 op p
}
p468t/a> 
 op p
return !!ta href="+code=n_error" class="sref">n_errort/a>;
p469t/a>}
p470t/a>
p471pta 
p472t/a>
lxr.linux.no kindly hosted by Redpill Linpro ASt/a>, provider of Linuxpconsulting and operan> s services since 1995.