diff options
Diffstat (limited to 'scripts/recordmcount.c')
| -rw-r--r-- | scripts/recordmcount.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index 37c59654c133..78054a41d134 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c | |||
| @@ -118,6 +118,34 @@ umalloc(size_t size) | |||
| 118 | return addr; | 118 | return addr; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | static unsigned char ideal_nop5_x86_64[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 }; | ||
| 122 | static unsigned char ideal_nop5_x86_32[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 }; | ||
| 123 | static unsigned char *ideal_nop; | ||
| 124 | |||
| 125 | static char rel_type_nop; | ||
| 126 | |||
| 127 | static int (*make_nop)(void *map, size_t const offset); | ||
| 128 | |||
| 129 | static int make_nop_x86(void *map, size_t const offset) | ||
| 130 | { | ||
| 131 | uint32_t *ptr; | ||
| 132 | unsigned char *op; | ||
| 133 | |||
| 134 | /* Confirm we have 0xe8 0x0 0x0 0x0 0x0 */ | ||
| 135 | ptr = map + offset; | ||
| 136 | if (*ptr != 0) | ||
| 137 | return -1; | ||
| 138 | |||
| 139 | op = map + offset - 1; | ||
| 140 | if (*op != 0xe8) | ||
| 141 | return -1; | ||
| 142 | |||
| 143 | /* convert to nop */ | ||
| 144 | ulseek(fd_map, offset - 1, SEEK_SET); | ||
| 145 | uwrite(fd_map, ideal_nop, 5); | ||
| 146 | return 0; | ||
| 147 | } | ||
| 148 | |||
| 121 | /* | 149 | /* |
| 122 | * Get the whole file as a programming convenience in order to avoid | 150 | * Get the whole file as a programming convenience in order to avoid |
| 123 | * malloc+lseek+read+free of many pieces. If successful, then mmap | 151 | * malloc+lseek+read+free of many pieces. If successful, then mmap |
| @@ -301,7 +329,11 @@ do_file(char const *const fname) | |||
| 301 | w2(ehdr->e_machine), fname); | 329 | w2(ehdr->e_machine), fname); |
| 302 | fail_file(); | 330 | fail_file(); |
| 303 | break; | 331 | break; |
| 304 | case EM_386: reltype = R_386_32; break; | 332 | case EM_386: |
| 333 | reltype = R_386_32; | ||
| 334 | make_nop = make_nop_x86; | ||
| 335 | ideal_nop = ideal_nop5_x86_32; | ||
| 336 | break; | ||
| 305 | case EM_ARM: reltype = R_ARM_ABS32; | 337 | case EM_ARM: reltype = R_ARM_ABS32; |
| 306 | altmcount = "__gnu_mcount_nc"; | 338 | altmcount = "__gnu_mcount_nc"; |
| 307 | break; | 339 | break; |
| @@ -312,7 +344,11 @@ do_file(char const *const fname) | |||
| 312 | case EM_S390: /* reltype: e_class */ gpfx = '_'; break; | 344 | case EM_S390: /* reltype: e_class */ gpfx = '_'; break; |
| 313 | case EM_SH: reltype = R_SH_DIR32; break; | 345 | case EM_SH: reltype = R_SH_DIR32; break; |
| 314 | case EM_SPARCV9: reltype = R_SPARC_64; gpfx = '_'; break; | 346 | case EM_SPARCV9: reltype = R_SPARC_64; gpfx = '_'; break; |
| 315 | case EM_X86_64: reltype = R_X86_64_64; break; | 347 | case EM_X86_64: |
| 348 | make_nop = make_nop_x86; | ||
| 349 | ideal_nop = ideal_nop5_x86_64; | ||
| 350 | reltype = R_X86_64_64; | ||
| 351 | break; | ||
| 316 | } /* end switch */ | 352 | } /* end switch */ |
| 317 | 353 | ||
| 318 | switch (ehdr->e_ident[EI_CLASS]) { | 354 | switch (ehdr->e_ident[EI_CLASS]) { |
