From 6c1e76280ee57b346b8a02fc37dc340c63d8579f Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sun, 24 Sep 2017 00:29:50 +0200 Subject: [PATCH] don't include relocs for undefined symbols - they should stay at absolute NULL --- Elf2Mac/Elf2Mac.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Elf2Mac/Elf2Mac.cc b/Elf2Mac/Elf2Mac.cc index c163e864e3..ae71735ee0 100644 --- a/Elf2Mac/Elf2Mac.cc +++ b/Elf2Mac/Elf2Mac.cc @@ -101,6 +101,13 @@ void ElfToFlt(string input, string output) GElf_Rela rela; gelf_getrela(data, i, &rela); + GElf_Sym sym; + if(gelf_getsym(symtabData, GELF_R_SYM(rela.r_info),&sym) != 0) + { + if(sym.st_shndx == SHN_UNDEF) + continue; + } + if(GELF_R_TYPE(rela.r_info) == R_68K_32) relocs.push_back(rela.r_offset); //printf("rel: %d %d %x %x\n", (int)GELF_R_TYPE(rela.r_info), (int)GELF_R_SYM(rela.r_info), (unsigned)rela.r_addend, (unsigned)rela.r_offset);