Lines Matching +full:loc +full:- +full:code

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (C) 1999-2019 Alibaba Group Holding Limited. by:
9 * Copyright 2011 - 2012 Cavium, Inc.
11 * Based on code taken from recortmcount.c which is:
20 * Strategy: alter the vmlinux file in-place.
120 return r8(&ehdr->e64.e_shoff); in ehdr64_shoff()
125 return r(&ehdr->e32.e_shoff); in ehdr32_shoff()
136 return r2(&ehdr->e64.e_##fn_name); \
141 return r2(&ehdr->e32.e_##fn_name); \
156 return r(&shdr->e64.sh_##fn_name); \ in EHDR_HALF()
161 return r(&shdr->e32.sh_##fn_name); \
172 return r8(&shdr->e64.sh_##fn_name); \
177 return r(&shdr->e32.sh_##fn_name); \
188 return r(&shdr->e64.sh_##fn_name); \
193 return r(&shdr->e32.sh_##fn_name); \
212 return r8(&sym->e64.st_##fn_name); \
217 return r(&sym->e32.st_##fn_name); \
228 return r(&sym->e64.st_##fn_name); \
233 return r(&sym->e32.st_##fn_name); \
244 return r2(&sym->e64.st_##fn_name); \
249 return r2(&sym->e32.st_##fn_name); \
259 return ELF64_ST_TYPE(sym->e64.st_info);
264 return ELF32_ST_TYPE(sym->e32.st_info); in sym32_type()
281 return r8((uint64_t *)&rela->e64.r_##fn_name); \ in SYM_WORD()
286 return r((uint32_t *)&rela->e32.r_##fn_name); \
300 w8(val, (uint64_t *)&rela->e64.r_addend);
305 w(val, (uint32_t *)&rela->e32.r_addend); in rela32_write_addend()
399 * the way to -256..-1, to avoid conflicting with real section
402 #define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1))
409 /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
427 return -1; in compare_extable_32()
437 return -1; in compare_extable_64()
482 return -1; in orc_sort_cmp()
486 * to ensure the lookup code skips them in favor of real entries. in orc_sort_cmp()
490 orc_a = g_orc_table + (a - g_orc_ip_table); in orc_sort_cmp()
491 orc_b = g_orc_table + (b - g_orc_ip_table); in orc_sort_cmp()
492 if (orc_a->type == ORC_TYPE_UNDEFINED && orc_b->type == ORC_TYPE_UNDEFINED) in orc_sort_cmp()
494 return orc_a->type == ORC_TYPE_UNDEFINED ? -1 : 1; in orc_sort_cmp()
542 g_orc_ip_table[i] = tmp_orc_ip_table[idxs[i]] - i * sizeof(int); in sort_orctable()
561 return -1; in compare_values_64()
571 return -1; in compare_values_32()
588 /* List of functions created by: nm -S vmlinux */
594 #define FUNC_BLK_MASK (FUNC_BLK_SIZE - 1)
605 return -1; in add_field()
609 fi->addr = addr; in add_field()
610 fi->size = size; in add_field()
623 if (key + before_func < a->addr) in cmp_func_addr()
624 return -1; in cmp_func_addr()
625 return key >= a->addr + a->size; in cmp_func_addr()
640 if (a->addr < b->addr) in cmp_funcs()
641 return -1; in cmp_funcs()
642 return a->addr > b->addr; in cmp_funcs()
655 return -1; in parse_symbols()
669 return -1; in parse_symbols()
726 return -1; in fill_relocs()
734 return -1; in fill_relocs()
818 uint64_t offset = emloc->start_mcount_loc - shdr_addr(emloc->init_data_sec) in sort_mcount_loc()
819 + shdr_offset(emloc->init_data_sec); in sort_mcount_loc()
820 uint64_t size = emloc->stop_mcount_loc - emloc->start_mcount_loc; in sort_mcount_loc()
821 unsigned char *start_loc = (void *)emloc->ehdr + offset; in sort_mcount_loc()
822 Elf_Ehdr *ehdr = emloc->ehdr; in sort_mcount_loc()
834 count = fill_relocs(vals, size, ehdr, emloc->start_mcount_loc); in sort_mcount_loc()
875 replace_relocs(vals, size, ehdr, emloc->start_mcount_loc); in sort_mcount_loc()
893 sym = (void *)emloc->ehdr + shdr_offset(symtab_sec); in get_mcount_loc()
898 emloc->start_mcount_loc = sym_value(sym); in get_mcount_loc()
902 emloc->stop_mcount_loc = sym_value(sym); in get_mcount_loc()
909 if (!emloc->start_mcount_loc) { in get_mcount_loc()
914 if (!emloc->stop_mcount_loc) { in get_mcount_loc()
927 int rc = -1; in do_sort()
1106 ((void *)sort_needed_sym - (void *)symtab) / symentsize, in do_sort()
1111 sym_value(sort_needed_sym) - shdr_addr(sort_needed_sec); in do_sort()
1128 rc = -1; in do_sort()
1146 rc = -1; in do_sort()
1162 return -1; in compare_relative_table()
1177 uint32_t *loc = (uint32_t *)(extab_image + i); in sort_relative_table() local
1178 w(r(loc) + i, loc); in sort_relative_table()
1187 uint32_t *loc = (uint32_t *)(extab_image + i); in sort_relative_table() local
1188 w(r(loc) - i, loc); in sort_relative_table()
1198 uint32_t *loc = (uint32_t *)(extab_image + i); in sort_relative_table_with_data() local
1200 w(r(loc) + i, loc); in sort_relative_table_with_data()
1201 w(r(loc + 1) + i + 4, loc + 1); in sort_relative_table_with_data()
1211 uint32_t *loc = (uint32_t *)(extab_image + i); in sort_relative_table_with_data() local
1213 w(r(loc) - i, loc); in sort_relative_table_with_data()
1214 w(r(loc + 1) - (i + 4), loc + 1); in sort_relative_table_with_data()
1226 switch (ehdr->e32.e_ident[EI_DATA]) { in do_file()
1243 ehdr->e32.e_ident[EI_DATA], fname); in do_file()
1244 return -1; in do_file()
1247 if (memcmp(ELFMAG, ehdr->e32.e_ident, SELFMAG) != 0 || in do_file()
1248 (r2(&ehdr->e32.e_type) != ET_EXEC && r2(&ehdr->e32.e_type) != ET_DYN) || in do_file()
1249 ehdr->e32.e_ident[EI_VERSION] != EV_CURRENT) { in do_file()
1251 return -1; in do_file()
1254 switch (r2(&ehdr->e32.e_machine)) { in do_file()
1284 r2(&ehdr->e32.e_machine), fname); in do_file()
1285 return -1; in do_file()
1288 switch (ehdr->e32.e_ident[EI_CLASS]) { in do_file()
1317 if (r2(&ehdr->e32.e_ehsize) != sizeof(Elf32_Ehdr) || in do_file()
1318 r2(&ehdr->e32.e_shentsize) != sizeof(Elf32_Shdr)) { in do_file()
1321 return -1; in do_file()
1354 if (r2(&ehdr->e64.e_ehsize) != sizeof(Elf64_Ehdr) || in do_file()
1355 r2(&ehdr->e64.e_shentsize) != sizeof(Elf64_Shdr)) { in do_file()
1359 return -1; in do_file()
1366 ehdr->e32.e_ident[EI_CLASS], fname); in do_file()
1367 return -1; in do_file()
1375 int i, n_error = 0; /* gcc-4.3.0 false positive complaint */ in main()
1385 return -1; in main()
1389 fprintf(stderr, "usage: sorttable [-s nm-file] vmlinux...\n"); in main()
1394 if ((argc - optind) < 1) { in main()