@@ -50,8 +50,6 @@ extern bool option_debug;
5050 } \
5151 while (false )
5252
53- typedef std::set<intptr_t > RelaInfo;
54-
5553/*
5654 * Insert target information.
5755 */
@@ -251,7 +249,7 @@ static void CFGCodeAnalysis(const ELF *elf, bool pic, const Instr *Is,
251249 * Section analysis pass: find potential code pointers in data.
252250 */
253251static void CFGSectionAnalysis (const ELF *elf, bool pic, const char *name,
254- const Elf64_Shdr *shdr, const Instr *Is, size_t size, const RelaInfo relas,
252+ const Elf64_Shdr *shdr, const Instr *Is, size_t size,
255253 const std::set<intptr_t > &tables, Targets &targets)
256254{
257255 if ((shdr->sh_flags & SHF_EXECINSTR) != 0 || shdr->sh_addr == 0x0 )
@@ -316,26 +314,6 @@ static void CFGSectionAnalysis(const ELF *elf, bool pic, const char *name,
316314 }
317315 }
318316 }
319-
320- if (shdr->sh_type == SHT_PROGBITS)
321- {
322- // Scan for code pointers using relocation information.
323- auto bounds = getBounds<int64_t >(sh_data, sh_data + sh_size);
324- for (const int64_t *p = bounds.first ; p < bounds.second ; p++)
325- {
326- intptr_t offset = (intptr_t )shdr->sh_addr +
327- ((intptr_t )p - (intptr_t )sh_data);
328- auto i = relas.find (offset);
329- if (i == relas.end ())
330- continue ;
331-
332- intptr_t target = *p;
333- if (findInstr (Is, size, target) < 0 )
334- continue ;
335- DEBUG (targets, target, " Reloc : %p (F)" , (void *)target);
336- addTarget (target, TARGET_INDIRECT | TARGET_FUNCTION, targets);
337- }
338- }
339317 }
340318}
341319
@@ -347,7 +325,6 @@ static void CFGDataAnalysis(const ELF *elf, bool pic, const Instr *Is,
347325{
348326 // Gather relocation information:
349327 const SectionInfo §ions = getELFSectionInfo (elf);
350- RelaInfo relas;
351328 for (const auto &entry: sections)
352329 {
353330 const Elf64_Shdr *shdr = entry.second ;
@@ -359,16 +336,19 @@ static void CFGDataAnalysis(const ELF *elf, bool pic, const Instr *Is,
359336 const Elf64_Rela *rela_end = rela + sh_size / sizeof (Elf64_Rela);
360337 for (; rela < rela_end; rela++)
361338 {
362- if (ELF64_R_TYPE (rela->r_info ) == R_X86_64_RELATIVE &&
363- rela->r_addend == 0 )
364- relas.insert (rela->r_offset );
339+ if (ELF64_R_TYPE (rela->r_info ) == R_X86_64_RELATIVE)
340+ {
341+ intptr_t target = (intptr_t )rela->r_addend ;
342+ DEBUG (targets, target, " Reloc : %p (F)" , (void *)target);
343+ addTarget (target, TARGET_INDIRECT | TARGET_FUNCTION, targets);
344+ }
365345 }
366346 }
367347
368348 // Analyze each data section:
369349 for (const auto &entry: sections)
370350 CFGSectionAnalysis (elf, pic, entry.first , entry.second , Is, size,
371- relas, tables, targets);
351+ tables, targets);
372352}
373353
374354/*
0 commit comments