Lines Matching +full:- +full:alt
1 // SPDX-License-Identifier: GPL-2.0-or-later
54 void __weak arch_handle_alternative(unsigned short feature, struct special_alt *alt) in arch_handle_alternative() argument
60 struct special_alt *alt) in get_alt_entry() argument
65 offset = idx * entry->size; in get_alt_entry()
67 alt->group = entry->group; in get_alt_entry()
68 alt->jump_or_nop = entry->jump_or_nop; in get_alt_entry()
70 if (alt->group) { in get_alt_entry()
71 alt->orig_len = *(unsigned char *)(sec->data->d_buf + offset + in get_alt_entry()
72 entry->orig_len); in get_alt_entry()
73 alt->new_len = *(unsigned char *)(sec->data->d_buf + offset + in get_alt_entry()
74 entry->new_len); in get_alt_entry()
77 if (entry->feature) { in get_alt_entry()
80 feature = *(unsigned short *)(sec->data->d_buf + offset + in get_alt_entry()
81 entry->feature); in get_alt_entry()
82 arch_handle_alternative(feature, alt); in get_alt_entry()
85 orig_reloc = find_reloc_by_dest(elf, sec, offset + entry->orig); in get_alt_entry()
87 WARN_FUNC("can't find orig reloc", sec, offset + entry->orig); in get_alt_entry()
88 return -1; in get_alt_entry()
90 if (orig_reloc->sym->type != STT_SECTION) { in get_alt_entry()
91 WARN_FUNC("don't know how to handle non-section reloc symbol %s", in get_alt_entry()
92 sec, offset + entry->orig, orig_reloc->sym->name); in get_alt_entry()
93 return -1; in get_alt_entry()
96 alt->orig_sec = orig_reloc->sym->sec; in get_alt_entry()
97 alt->orig_off = orig_reloc->addend; in get_alt_entry()
99 if (!entry->group || alt->new_len) { in get_alt_entry()
100 new_reloc = find_reloc_by_dest(elf, sec, offset + entry->new); in get_alt_entry()
103 sec, offset + entry->new); in get_alt_entry()
104 return -1; in get_alt_entry()
107 alt->new_sec = new_reloc->sym->sec; in get_alt_entry()
108 alt->new_off = (unsigned int)new_reloc->addend; in get_alt_entry()
111 if (alt->new_off >= 0x7ffffff0) in get_alt_entry()
112 alt->new_off -= 0x7ffffff0; in get_alt_entry()
128 struct special_alt *alt; in special_get_alts() local
133 for (entry = entries; entry->sec; entry++) { in special_get_alts()
134 sec = find_section_by_name(elf, entry->sec); in special_get_alts()
138 if (sec->len % entry->size != 0) { in special_get_alts()
140 sec->name, entry->size); in special_get_alts()
141 return -1; in special_get_alts()
144 nr_entries = sec->len / entry->size; in special_get_alts()
147 alt = malloc(sizeof(*alt)); in special_get_alts()
148 if (!alt) { in special_get_alts()
150 return -1; in special_get_alts()
152 memset(alt, 0, sizeof(*alt)); in special_get_alts()
154 ret = get_alt_entry(elf, entry, sec, idx, alt); in special_get_alts()
158 list_add_tail(&alt->list, alts); in special_get_alts()