diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2008-11-24 17:23:27 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2008-11-24 17:23:27 +0000 |
commit | ff77764606316d1e448ef97cdd5380de36810114 (patch) | |
tree | b1e15c8566025609fb8d4fb11b7a3b9baa7e4269 /usr.sbin/crunchgen/elf_hide.c | |
parent | 4c4620904ad302bcb3be1ff350897a9b433d708c (diff) |
Change mips detection in crunchgen from ifdef to command line flag
ok deraadt@, fkr@, rainer@. manpage cleanup thanks to jmc@
Diffstat (limited to 'usr.sbin/crunchgen/elf_hide.c')
-rw-r--r-- | usr.sbin/crunchgen/elf_hide.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/usr.sbin/crunchgen/elf_hide.c b/usr.sbin/crunchgen/elf_hide.c index 148a3946ff1..3d084aa6c99 100644 --- a/usr.sbin/crunchgen/elf_hide.c +++ b/usr.sbin/crunchgen/elf_hide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf_hide.c,v 1.2 2008/09/08 20:42:24 deraadt Exp $ */ +/* $OpenBSD: elf_hide.c,v 1.3 2008/11/24 17:23:26 drahn Exp $ */ /* * Copyright (c) 1997 Dale Rahn. @@ -40,6 +40,8 @@ #ifdef _NLIST_DO_ELF #include <sys/exec_elf.h> +extern int elf_mangle; + void load_strtab(Elf_Ehdr * pehdr, char *pexe); void dump_strtab(); char *get_str(int indx); @@ -304,15 +306,9 @@ hide_sym(Elf_Ehdr * ehdr, Elf_Shdr * symsect, Elf_Sym * symtab, int symtabsize, int symtabsecnum) { int i; -#ifndef __mips__ unsigned char info; -#endif 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 && @@ -325,24 +321,26 @@ hide_sym(Elf_Ehdr * ehdr, Elf_Shdr * symsect, 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. - */ - { + if (!elf_mangle) { + info = psymtab->st_info; + info = info & 0xf; + psymtab->st_info = info; + } else { + /* + * XXX This is a small ugly hack to be able to + * XXX use chrunchide with MIPS. + * XXX Because MIPS needs global symbols to stay + * XXX global (has to do with GOT), we mess + * XXX around with the symbol names instead. + * XXX For most uses this will be no problem, + * XXX symbols are stripped anyway. + * XXX However, if many one character + * XXX symbols exist, names may clash. + */ char *p; u_int32_t n, z; + u_int32_t f; + f = arc4random(); z = f++; p = get_str(psymtab->st_name); @@ -356,8 +354,6 @@ hide_sym(Elf_Ehdr * ehdr, Elf_Shdr * symsect, p[n] += arc4random(); } } - -#endif #ifdef DEBUG printf("st_info %x\n", psymtab->st_info); #endif |