Ticket #10: 2_beos_partial.diff
| File 2_beos_partial.diff, 21.1 kB (added by zadig, 39 years ago) |
|---|
-
README.BEOS
diff -urN ./README.BEOS ../elfsh.mine/README.BEOS
old new 1 ./configure --enable-32 --enable-readline --use-etags --set-shell "\"/bin/sh\"" --set-editor "\"vi\"" --set-modpath "\"/boot/home/config/share/elfsh/\"" --prefix "\"/boot/home/config\"" --set-lib-path "\"/boot/beos/system/lib;/boot/home/config/lib\"" 2 3 config.h: 4 remove -rdynamic 5 6 export RANLIB="ranlib" 7 8 Makefile: 9 BASEPATH = $(DESTDIR) 10 comment libmalloc, e2dbg 11 -
e2dbg/dumpregs.c
diff -urN ./e2dbg/dumpregs.c ../elfsh.mine/e2dbg/dumpregs.c
old new 41 41 42 42 #if defined(__amd64__) && defined(__FreeBSD__) 43 43 44 #elif defined(__FreeBSD__) 44 #elif defined(__FreeBSD__) || defined(__BEOS__) 45 45 vm_dumpreg("EAX", e2dbgworld.curthread->context->uc_mcontext.mc_eax); 46 46 vm_dumpreg("EBX", e2dbgworld.curthread->context->uc_mcontext.mc_ebx); 47 47 vm_dumpreg("ECX", e2dbgworld.curthread->context->uc_mcontext.mc_ecx); -
e2dbg/include/e2dbg.h
diff -urN ./e2dbg/include/e2dbg.h ../elfsh.mine/e2dbg/include/e2dbg.h
old new 9 9 #ifndef __E2DBG_H__ 10 10 #define __E2DBG_H__ 11 11 12 #ifdef __BEOS__ 13 typedef char siginfo_t; 14 #define SA_SIGINFO NSIG 15 #define sa_sigaction sa_handler 16 #endif 17 12 18 #define __DEBUG_E2DBG__ 0 13 19 #define __DEBUG_MUTEX__ 1 14 20 #define __DEBUG_BP__ 0 -
e2dbg/xmalloc.c
diff -urN ./e2dbg/xmalloc.c ../elfsh.mine/e2dbg/xmalloc.c
old new 149 149 150 150 151 151 /* Wrapper for calloc */ 152 #if __FreeBSD__ > 5152 #if (__FreeBSD__ > 5) || defined(__BEOS__) 153 153 void *calloc(size_t t, size_t nbr) 154 154 #else 155 155 void *calloc(size_t t, u_int nbr) -
libasm/include/libasm.h
diff -urN ./libasm/include/libasm.h ../elfsh.mine/libasm/include/libasm.h
old new 10 10 11 11 12 12 #include <sys/types.h> 13 #ifdef __BEOS__ 14 #include <stdint.h> 15 #endif 13 16 #include <stdio.h> 14 17 #include <string.h> 15 18 #include <stdlib.h> -
libasm/src/arch/ia32/ei386-7.c
diff -urN ./libasm/src/arch/ia32/ei386-7.c ../elfsh.mine/libasm/src/arch/ia32/ei386-7.c
old new 12 12 */ 13 13 14 14 int i386_group12(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 15 struct s_modrm *modrm = (struct s_modrm *) opcode + 1; 15 16 new->ptr_instr = opcode; 16 17 new->len += 1; 17 struct s_modrm *modrm = (struct s_modrm *) opcode + 1;18 18 19 19 switch (modrm->r) { 20 20 case 2: … … 64 64 */ 65 65 66 66 int i386_group14(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 67 struct s_modrm *modrm = (struct s_modrm *) opcode + 1; 67 68 new->ptr_instr = opcode; 68 69 new->len += 1; 69 struct s_modrm *modrm = (struct s_modrm *) opcode + 1;70 70 71 71 switch (modrm->r) { 72 72 case 2: -
libelfsh/got.c
diff -urN ./libelfsh/got.c ../elfsh.mine/libelfsh/got.c
old new 420 420 421 421 422 422 423 424 /*425 ** Only used on BeoS426 ** Tested and developed by zadig@myrealbox.com427 **428 */429 int elfsh_get_got_symbol_reloc(elfshobj_t *file,430 uint8 *name,431 elfsh_Rel *rel_entry)432 {433 elfshsect_t *got, *rel_got;434 u_int index, got_rel_index;435 u_int entsz;436 int got_index;437 elfsh_Off off;438 void *data;439 440 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__);441 442 /* Sanity checks */443 entsz = elfsh_get_pltentsz(file);444 if (entsz < 0)445 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__,446 "Invalid PLT entry size", -1);447 448 if (NULL == elfsh_get_dynsymtab(file, NULL))449 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__,450 "Unable to get DYNSYM", -1);451 452 if (NULL == elfsh_get_symtab(file, NULL))453 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__,454 "Unable to get SYMTAB", -1);455 456 /* get got section index */457 got = elfsh_get_section_by_name(file,458 ELFSH_SECTION_NAME_GOT,459 &got_index, NULL, NULL);460 if (got == NULL)461 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__,462 "Unable to get GOT", -1);463 464 /* search the got relocation section */465 rel_got = NULL;466 for (got_rel_index = 0; got_rel_index < file->hdr->e_shnum; got_rel_index++)467 {468 rel_got = elfsh_get_section_by_index(file, got_rel_index,469 NULL, NULL);470 if (rel_got->shdr->sh_info == got_index)471 break;472 }473 474 if ((rel_got == NULL) || (rel_got->shdr->sh_info != got_index))475 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__,476 "Unable to get GOT relocations", -1);477 478 /* search for the requested symbol */479 off = entsz;480 data = elfsh_get_raw(rel_got);481 for (index = 0;482 index < (rel_got->shdr->sh_size / rel_got->shdr->sh_entsize);483 off += entsz, index ++)484 {485 elfsh_Rel *cur_rel;486 cur_rel = ((elfsh_Rel*) data) + index;487 if(strcmp(elfsh_get_symname_from_reloc(file, cur_rel), name) == 0)488 {489 *rel_entry = *cur_rel;490 ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);491 }492 }493 494 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__,495 "Symbol not found", -1);496 }497 498 499 500 -
libelfsh/hooks.c
diff -urN ./libelfsh/hooks.c ../elfsh.mine/libelfsh/hooks.c
old new 641 641 ELFSH_OS_OPENBSD, elfsh_hijack_plt_ia32); 642 642 elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 643 643 ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia32); 644 elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 645 ELFSH_OS_BEOS, elfsh_hijack_plt_ia32); 644 646 645 647 /* Usual PLT targets for ET_EXEC/Sparc32 */ 646 648 elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, … … 729 731 ELFSH_OS_OPENBSD, elfsh_void_altplthandler); 730 732 elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 731 733 ELFSH_OS_SOLARIS, elfsh_void_altplthandler); 734 elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 735 ELFSH_OS_BEOS, elfsh_void_altplthandler); 732 736 733 737 /* Usual ALTPLT targets for ET_EXEC/Sparc32 */ 734 738 elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, … … 818 822 ELFSH_OS_OPENBSD, elfsh_relocate_ia32); 819 823 elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 820 824 ELFSH_OS_SOLARIS, elfsh_relocate_ia32); 825 elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 826 ELFSH_OS_BEOS, elfsh_relocate_ia32); 821 827 822 828 /* Usual REL targets for ET_EXEC/Sparc32 */ 823 829 elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, … … 906 912 ELFSH_OS_OPENBSD, elfsh_cflow_ia32); 907 913 elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 908 914 ELFSH_OS_SOLARIS, elfsh_cflow_ia32); 915 elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 916 ELFSH_OS_BEOS, elfsh_cflow_ia32); 909 917 910 918 /* Usual CFLOW targets for ET_EXEC/IA64 */ 911 919 elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, … … 980 988 ELFSH_OS_SOLARIS, elfsh_cflow_mips64); 981 989 elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 982 990 ELFSH_OS_LINUX, elfsh_cflow_ia32); 991 elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 992 ELFSH_OS_BEOS, elfsh_cflow_ia32); 983 993 984 994 /* Usual REL/PLT/ALTPLT targets for ET_DYN/x86 */ 985 995 elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, … … 1043 1053 ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); 1044 1054 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 1045 1055 ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); 1056 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 1057 ELFSH_OS_BEOS, elfsh_encodeplt_ia32); 1046 1058 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1047 1059 ELFSH_OS_LINUX, elfsh_encodeplt_ia32); 1048 1060 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, … … 1053 1065 ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); 1054 1066 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1055 1067 ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); 1068 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1069 ELFSH_OS_BEOS, elfsh_encodeplt_ia32); 1056 1070 1057 1071 /* Usual ENCODEPLT1 targets for ET_EXEC/IA32 */ 1058 1072 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, … … 1065 1079 ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); 1066 1080 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 1067 1081 ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); 1082 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 1083 ELFSH_OS_BEOS, elfsh_encodeplt1_ia32); 1068 1084 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1069 1085 ELFSH_OS_LINUX, elfsh_encodeplt1_ia32); 1070 1086 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, … … 1075 1091 ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); 1076 1092 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1077 1093 ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); 1094 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1095 ELFSH_OS_BEOS, elfsh_encodeplt1_ia32); 1078 1096 1079 1097 /*** Now EXTPLT handlers ***/ 1080 1098 … … 1089 1107 ELFSH_OS_OPENBSD, elfsh_extplt_ia32); 1090 1108 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 1091 1109 ELFSH_OS_SOLARIS, elfsh_extplt_ia32); 1110 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, 1111 ELFSH_OS_BEOS, elfsh_extplt_ia32); 1092 1112 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1093 1113 ELFSH_OS_LINUX, elfsh_extplt_ia32); 1094 1114 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, … … 1099 1119 ELFSH_OS_OPENBSD, elfsh_extplt_ia32); 1100 1120 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1101 1121 ELFSH_OS_SOLARIS, elfsh_extplt_ia32); 1122 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 1123 ELFSH_OS_BEOS, elfsh_extplt_ia32); 1102 1124 1103 1125 /***************************************/ 1104 1126 /****** ARGC arguments counting ******/ -
libelfsh/include/libelfsh/libelfsh-internal.h
diff -urN ./libelfsh/include/libelfsh/libelfsh-internal.h ../elfsh.mine/libelfsh/include/libelfsh/libelfsh-internal.h
old new 14 14 #define ELFSH_ERR_ARRAY sys_errlist[sys_nerr] 15 15 #endif 16 16 17 #ifdef __BEOS__ 18 /* the internal allocator is not ported yet. For elfsh it should be enough 19 * for the moment. The allocator will be ported to enable e2dbg support */ 20 #define elfsh_calloc calloc 21 #define elfsh_realloc realloc 22 #define elfsh_malloc malloc 23 #define elfsh_valloc valloc 24 #define elfsh_memalign memalign 25 #define elfsh_free free 26 #define __elfsh_libc_malloc_pthread_startup(first_time) 27 #else 17 28 /* Some calls defined in libmalloc */ 18 29 void *elfsh_calloc(size_t, char); 19 30 void *elfsh_realloc(void *, size_t); … … 22 33 void *elfsh_memalign(size_t t, u_int nbr); 23 34 void elfsh_free(void *); 24 35 void __elfsh_libc_malloc_pthread_startup(int first_time); 36 #endif 25 37 26 38 /* Safe calloc() */ 27 39 #define XALLOC(a, b, c) \ -
libelfsh/include/libelfsh.h
diff -urN ./libelfsh/include/libelfsh.h ../elfsh.mine/libelfsh/include/libelfsh.h
old new 18 18 #include <fcntl.h> 19 19 #include <errno.h> 20 20 #include <sys/stat.h> 21 #ifndef __BEOS__ 21 22 #include <sys/mman.h> 23 #endif 22 24 23 25 24 26 #include "elfsh-libc.h" … … 28 30 #include <libelfsh/libelfsh-compat.h> 29 31 30 32 #ifdef __BEOS__ 31 #include <bsd_mem.h> 33 #include <inttypes.h> 34 #include <stdint.h> 35 #include <bsd_mem.h> 36 #include <OS.h> 37 #include <bsd_mem.h> 32 38 #endif 33 39 34 40 … … 865 871 u_int elfsh_set_got_val(elfsh_Addr *got, elfsh_Addr val); 866 872 elfsh_Addr elfsh_get_got_addr(elfsh_Addr *got); 867 873 u_int elfsh_set_got_addr(elfsh_Addr *got, elfsh_Addr val); 868 int elfsh_get_got_symbol_reloc(elfshobj_t *file, uint8 *name,869 elfsh_Rel *rel_entry);870 874 int elfsh_endianize_got(elfshsect_t *_new); 871 875 elfshsect_t *elfsh_get_gotsct(elfshobj_t *file); 872 876 int elfsh_shift_got(elfshobj_t *file, u_int size); -
libelfsh/mips32.c
diff -urN ./libelfsh/mips32.c ../elfsh.mine/libelfsh/mips32.c
old new 509 509 GP = GP 510 510 */ 511 511 *HI16_dword += 512 VERIFY16(( ((old_HI16_dword << 16) + (short) A) + /* AHL */512 VERIFY16((elfsh_Addr)(((old_HI16_dword << 16) + (short) A) + /* AHL */ 513 513 GP - /* GP */ 514 514 (new->shdr->sh_addr + HI16_cur->r_offset) - /* P */ 515 515 (short) (((old_HI16_dword << 16) + (short) A) + /* AHL */ … … 539 539 540 540 if (ISGPDISP(cur)) 541 541 { 542 *dword = VERIFY16(((old_HI16_dword << 16) + (short) A) + GP +P + 4);542 *dword = VERIFY16(((old_HI16_dword << 16) + (short) A) + (elfsh_Addr)GP + (elfsh_Addr)P + 4); 543 543 ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); 544 544 } 545 545 -
libelfsh/plt.c
diff -urN ./libelfsh/plt.c ../elfsh.mine/libelfsh/plt.c
old new 79 79 80 80 if (sym->st_size != file->secthash[ELFSH_SECTION_PLT]->shdr->sh_size) 81 81 { 82 if ( (file->hdr->e_type == ET_DYN) && (sym->st_value == 0) ) 83 ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); 84 82 85 if (INTERVAL(file->secthash[ELFSH_SECTION_PLT]->shdr->sh_addr, 83 86 sym->st_value, 84 87 file->secthash[ELFSH_SECTION_PLT]->shdr->sh_addr + -
libelfsh/runtime.c
diff -urN ./libelfsh/runtime.c ../elfsh.mine/libelfsh/runtime.c
old new 33 33 34 34 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 35 35 36 #ifdef __BEOS__ 37 if (elfsh_segment_is_readable(segment)) 38 prot |= B_READ_AREA; 39 if (elfsh_segment_is_writable(segment)) 40 prot |= B_WRITE_AREA; 41 if (elfsh_segment_is_executable(segment)) 42 prot |= B_READ_AREA; 43 #else 36 44 if (elfsh_segment_is_readable(segment)) 37 45 prot |= PROT_READ; 38 46 if (elfsh_segment_is_writable(segment)) 39 47 prot |= PROT_WRITE; 40 48 if (elfsh_segment_is_executable(segment)) 41 49 prot |= PROT_EXEC; 50 #endif 42 51 43 52 #if __DEBUG_RUNTIME__ 44 53 printf("[DEBUG_RUNTIME] MMAP: " XFMT " of %d bytes \n", segment->p_vaddr, segment->p_memsz); … … 62 71 zero, 0); 63 72 close(zero); 64 73 } 74 #elif defined(__BEOS__) 75 if(create_area("ElfSh", (void **) &addr, B_ANY_ADDRESS, segment->p_memsz, 76 B_NO_LOCK, prot) < 0) 77 { 78 addr = 0; 79 } 80 65 81 #else 66 82 addr = (elfsh_Addr) mmap((void *) 0, segment->p_memsz, 67 83 prot, … … 92 108 int elfsh_runtime_unmap(elfsh_Phdr *segment) 93 109 { 94 110 int ret; 111 #ifdef __BEOS__ 112 area_id area; 113 #endif 95 114 96 115 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 97 116 117 #ifdef __BEOS__ 118 area = area_for((void*)(segment->p_vaddr)); 119 ret = delete_area(area); 120 #else 98 121 ret = munmap((void *) segment->p_vaddr, segment->p_memsz); 122 #endif 99 123 100 124 //if (!ret) 101 125 //memset(segment, 0x00, sizeof(elfsh_Phdr)); … … 146 170 elfsh_Phdr *phdr; 147 171 int retval; 148 172 int prot; 173 #ifdef __BEOS__ 174 area_id area; 175 #endif 149 176 150 177 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 151 178 if (!elfsh_is_debug_mode()) … … 159 186 phdr = elfsh_get_parent_segment(file, sect); 160 187 prot = 0; 161 188 189 #ifdef __BEOS__ 190 if (elfsh_segment_is_readable(phdr)) 191 prot |= B_READ_AREA; 192 if (elfsh_segment_is_writable(phdr)) 193 prot |= B_WRITE_AREA; 194 if (elfsh_segment_is_executable(phdr)) 195 prot |= B_READ_AREA; 196 197 area = area_for((void*)(addr)); 198 if(area == B_ERROR) 199 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 200 "Cannot find area", -1); 201 202 retval = set_area_protection(area, B_WRITE_AREA | B_READ_AREA); 203 #else 162 204 if (elfsh_segment_is_readable(phdr)) 163 205 prot |= PROT_READ; 164 206 if (elfsh_segment_is_writable(phdr)) … … 168 210 169 211 retval = mprotect((void *) (addr - addr % getpagesize()), 170 212 getpagesize(), PROT_READ | PROT_WRITE); 213 #endif 171 214 172 215 if (retval != 0) 173 216 { … … 186 229 int elfsh_mprotect(elfsh_Addr addr, uint32_t sz, int prot) 187 230 { 188 231 int retval; 232 #ifdef __BEOS__ 233 area_id area; 234 #endif 189 235 190 236 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 191 237 if (!elfsh_is_debug_mode()) 192 238 ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); 193 239 240 #ifdef __BEOS__ 241 area = area_for((void*)(addr)); 242 if(area == B_ERROR) 243 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 244 "Cannot find area", -1); 245 246 retval = set_area_protection(area, prot); 247 #else 194 248 retval = mprotect((void *) addr - addr % getpagesize(), 195 249 getpagesize(), prot); 250 #endif 196 251 197 252 if (retval != 0) 198 253 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, -
libmalloc/include/malloc-machine.h
diff -urN ./libmalloc/include/malloc-machine.h ../elfsh.mine/libmalloc/include/malloc-machine.h
old new 21 21 #ifndef _GENERIC_MALLOC_MACHINE_H 22 22 #define _GENERIC_MALLOC_MACHINE_H 23 23 24 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 24 #if defined(__BEOS__) 25 #include <SupportDefs.h> 26 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 25 27 #include <machine/atomic.h> 26 28 #elif !defined(IRIX) 27 29 #include <asm/atomic.h> -
libui/log.c
diff -urN ./libui/log.c ../elfsh.mine/libui/log.c
old new 60 60 61 61 static void logtofile(char *str) 62 62 { 63 63 char *tmp; 64 64 65 elfshpath_t *stripvar; 65 66 u_int len; 66 67 … … 73 74 ELFSH_NOPROFILE_OUT(); 74 75 75 76 /* We made only local modifications */ 76 char tmp[len+1];77 tmp = (char*)malloc(len+1); 77 78 strcpy(tmp, str); 78 79 79 80 stripvar = hash_get(&vars_hash, ELFSH_SLOGVAR); … … 94 95 len = strlen(tmp); 95 96 XWRITE(world.curjob->logfd, tmp, len, ); 96 97 98 free(tmp); 97 99 ELFSH_NOPROFILE_OUT(); 98 100 } 99 101 -
vm/include/elfsh.h
diff -urN ./vm/include/elfsh.h ../elfsh.mine/vm/include/elfsh.h
old new 984 984 int vm_getvarparams(u_int index, u_int argc, char **argv); 985 985 986 986 /* Libasm resolve handlers */ 987 void asm_do_resolve(void *data, u_intvaddr, char *, u_int);987 void asm_do_resolve(void *data, elfsh_Addr vaddr, char *, u_int); 988 988 char *vm_resolve(elfshobj_t *file, elfsh_Addr addr, elfsh_SAddr *roff); 989 989 990 990 /* General VM functions */ … … 1023 1023 int vm_version_unk(u_int ai, u_int i, char *id, char *n, char *t); 1024 1024 1025 1025 /* Disassembling and hexadecimal view functions */ 1026 u_int vm_display_instr(int, u_int, u_int, u_int, u_int,1026 u_int vm_display_instr(int, u_int, elfsh_Addr, u_int, u_int, 1027 1027 char *, u_int, char *); 1028 1028 int vm_display_section(elfshsect_t *s, char *name, elfshlist_t *re); 1029 1029 int vm_match_sht(elfshobj_t *file, elfshsect_t *l, elfshlist_t *actual); -
vm/trace.c
diff -urN ./vm/trace.c ../elfsh.mine/vm/trace.c
old new 296 296 int osize = strlen(tfname) + 3; 297 297 char rsofname[osize]; 298 298 char rtfname[osize]; 299 char **selfuncs; 299 300 300 301 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 301 302 … … 318 319 "Cannot init tmp files", (-1)); 319 320 320 321 /* Create temporary storage */ 321 char *selfuncs[symnum + dynsymnum + 1];322 selfuncs = elfsh_malloc(symnum+1 * sizeof(char)); 322 323 323 324 for (index = 0; index < symnum + dynsymnum + 1; index++) 324 325 selfuncs[index] = NULL; … … 334 335 335 336 /* If we didn't trace a function, we don't need to continue */ 336 337 if (!count) 338 { 339 elfsh_free(selfuncs); 337 340 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 338 341 "No function found", (-1)); 342 } 339 343 340 344 #if __DEBUG_TRACE__ 341 345 printf("[DEBUG TRACE] RENAME %s to %s\n", tfname, rtfname); … … 343 347 344 348 /* Compile the tmp c file to create a relocatable file to inject */ 345 349 if (rename(tfname, rtfname) < 0) 350 { 351 elfsh_free(selfuncs); 346 352 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 347 353 "Rename failed", (-1)); 354 } 348 355 349 356 snprintf(buf, BUFSIZ, "gcc -c %s -o %s", rtfname, rsofname); 350 357 vm_system(buf); … … 352 359 /* Load the new relocatable file for ET_REL injection */ 353 360 tobj = elfsh_map_obj(rsofname); 354 361 if (!tobj) 362 { 363 elfsh_free(selfuncs); 355 364 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 356 365 "Failed to load relocatable file", (-1)); 366 } 357 367 358 368 idx = elfsh_inject_etrel(world.curjob->current, tobj); 359 369 if (idx < 0) 370 { 371 elfsh_free(selfuncs); 360 372 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 361 373 "Failed to inject ET_REL with workspace", (-1)); 374 } 362 375 363 376 /* Hijack functions with the new functions injected */ 364 377 for (index = 0; index < count; index++) … … 382 395 selfuncs[index], 383 396 addr, NULL); 384 397 if (err < 0) 398 { 399 elfsh_free(selfuncs); 385 400 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 386 401 "Failed to hijack a function", (-1)); 402 } 387 403 } 388 404 389 405 vm_output("\n [*] Binary ready to be traced. You can now save and run it.\n\n"); 390 406 407 elfsh_free(selfuncs); 391 408 ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); 392 409 } 393 410
