void hide_sym(Elf_Ehdr * ehdr, Elf_Shdr * symsect, Elf_Sym * symtab, int symtabsize, int symtabsecnum) { int i; unsigned char info; Elf_Sym *psymtab; for (i = 0; i < (symtabsize / sizeof(Elf_Sym)); i++) { psymtab = &(symtab[i]); if ((psymtab->st_info & 0xf0) == 0x10 && (psymtab->st_shndx != SHN_UNDEF)) { if (in_keep_list(get_str(psymtab->st_name))) continue; #ifdef DEBUG printf("symbol %d:\n", i); printf("st_name %x \"%s\"\n", psymtab->st_name, get_str(psymtab->st_name)); printf("st_info %x\n", psymtab->st_info); #endif if (!elf_mangle) { info = psymtab->st_info; info = info & 0xf; psymtab->st_info = info; } else { mangle_str(get_str(psymtab->st_name)); } #ifdef DEBUG printf("st_info %x\n", psymtab->st_info); #endif } } reorder_syms(ehdr, symsect, symtab, symtabsize, symtabsecnum); }
void hide_sym(Elf_Ehdr * ehdr, Elf_Shdr * symsect, Elf_Sym * symtab, int symtabsize, int symtabsecnum) { int i; unsigned char info; Elf_Sym *psymtab; #ifdef __mips__ u_int32_t f = arc4random(); #endif for (i = 0; i < (symtabsize / sizeof(Elf_Sym)); i++) { psymtab = &(symtab[i]); if ((psymtab->st_info & 0xf0) == 0x10 && (psymtab->st_shndx != SHN_UNDEF)) { if (in_keep_list(get_str(psymtab->st_name))) continue; #ifdef DEBUG printf("symbol %d:\n", i); printf("st_name %x \"%s\"\n", psymtab->st_name, get_str(psymtab->st_name)); printf("st_info %x\n", psymtab->st_info); #endif #ifndef __mips__ info = psymtab->st_info; info = info & 0xf; psymtab->st_info = info; #else /* * XXX This is a small ugly hack to be able to use * XXX chrunchide with MIPS. * XXX Because MIPS needs global symbols to stay * XXX global (has to do with GOT), we mess around * XXX with the symbol names instead. For most uses * XXX this will be no problem, symbols are stripped * XXX anyway. However, if many one character * XXX symbols exist, names may clash. */ { char *p; u_int32_t n, z; z = f++; p = get_str(psymtab->st_name); n = strlen(p); if (n > 4) n = 4; while (n--) { p[n] = z; z >>= 8; while (p[n] == 0) p[n] += arc4random(); } } #endif #ifdef DEBUG printf("st_info %x\n", psymtab->st_info); #endif } } reorder_syms(ehdr, symsect, symtab, symtabsize, symtabsecnum); }