MCPcopy Create free account
hub / github.com/cinit/TMoe / findSymByName32

Function findSymByName32

app/src/main/cpp/utils/elfsym/ElfView.cpp:151–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151[[nodiscard]]
152static bool findSymByName32(const ElfView::ElfInfo &info, const char *symbol,
153 const Elf32_Sym **ppsym, uint32_t *psymidx) {
154 if (info.gnu_hash != nullptr) {
155 if (findLocalSymByGnuHash32(info, symbol, ppsym, psymidx)) {
156 return true;
157 }
158 // search the symtab
159 const uint32_t *gnuhashtab = static_cast<const uint32_t *>(info.gnu_hash);
160 const uint32_t symoffset = gnuhashtab[1];
161 const Elf32_Sym *symtab = static_cast<const Elf32_Sym *>(info.symtab);
162 for (uint32_t i = 0; i < symoffset; i++) {
163 const char *symname = info.symstr + symtab[i].st_name;
164 if (strcmp(symname, symbol) == 0) {
165 *psymidx = i;
166 *ppsym = &symtab[i];
167 return true;
168 }
169 }
170 return false;
171 } else if (info.chain != nullptr) {
172 const Elf32_Sym *target = nullptr;
173 uint32_t hash = elf_sysv_hash(symbol);
174 uint32_t index = info.bucket[hash % info.nbucket];
175 const auto *sym = static_cast<const Elf32_Sym *>(info.symtab);
176 if (!strcmp(info.symstr + sym[index].st_name, symbol)) {
177 target = sym + index;
178 }
179 if (!target) {
180 do {
181 index = info.chain[index];
182 if (!strcmp(info.symstr + sym[index].st_name, symbol)) {
183 target = sym + index;
184 break;
185 }
186 } while (index != 0);
187 }
188 if (target) {
189 *ppsym = target;
190 *psymidx = int(index);
191 return true;
192 }
193 }
194 return false;
195}
196
197[[nodiscard]]
198static bool findSymByName64(const ElfView::ElfInfo &info, const char *symbol,

Callers 2

getSymbolIndexMethod · 0.85

Calls 2

findLocalSymByGnuHash32Function · 0.85
elf_sysv_hashFunction · 0.85

Tested by

no test coverage detected