Ticket #10: 3_beos_complete.diff
| File 3_beos_complete.diff, 35.1 kB (added by zadig, 39 years ago) |
|---|
-
Makefile
diff -urN ./Makefile ../elfsh.mine/Makefile
old new 1 ## 2 ## Makefile 3 ## 4 ## Started on Fri Dec 7 06:54:35 2001 mayhem 5 ## Automatically generated from the configure script 6 ## 7 8 include ./config.h 9 10 CC = gcc 11 RM = rm -f 12 ETAGS = etags 13 CTAGS = ctags 14 DESTDIR = "/boot/home/config" 15 BASEPATH = $(DESTDIR) 16 MANPATH = $(BASEPATH)/share/man 17 MODPATH = $(BASEPATH)/share/elfsh/ 18 BINPATH = $(BASEPATH)/bin/ 19 LIBPATH = $(BASEPATH)/lib/ 20 INCPATH = $(BASEPATH)/include/ 21 RM = rm -f 22 23 all : world modules tags 24 world : 25 @echo 'Building e2dbg-libc ..' 26 @cd libc && $(MAKE) 27 @echo 'Libc-elfsh has been built successfully.' 28 # @echo 'Building e2dbg-libmalloc..' 29 # @cd libmalloc && $(MAKE) 30 # @echo 'Libmalloc-elfsh has been built successfully.' 31 @echo 'Building libasm...' 32 @cd libasm && $(MAKE) 33 @echo 'Libasm has been built successfully.' 34 @echo 'Building libelfsh...' 35 @cd libelfsh && $(MAKE) 36 @echo 'Libelfsh has been built successfully.' 37 @echo 'Building libui...' 38 @cd libui && $(MAKE) 39 @echo 'Libui has been built successfully.' 40 @echo 'Building libmjollnir...' 41 @cd libmjollnir && $(MAKE) 42 @echo 'Libmjollnir has been built successfully.' 43 @echo 'Building ELFsh ET_EXEC' 44 @cd vm && $(MAKE) 45 @echo 'ELFsh ET_EXEC has been built successfully.' 46 47 # @echo 'Building E2dbg' 48 # @cd e2dbg && $(MAKE) all 49 # @echo 'E2dbg has been built successfully.' 50 51 .PHONY: modules 52 modules: 53 @echo 'Building ELFsh modules suite...' 54 @cd modules && $(MAKE) 55 @echo 'ELFsh modules suite built successfully.' 56 57 install : all prepareDir mod_install 58 @cp vm/elfsh $(BINPATH)/ 59 # @cp e2dbg/e2dbg $(BINPATH)/ 60 @cp libc/libcelfsh.a $(LIBPATH) 61 # @cp libmalloc/libmalloc-e2dbg.a $(LIBPATH) 62 @cp libelfsh/libelfsh.a libelfsh/libelfsh.so $(LIBPATH) 63 @cp libasm/libasm.a $(LIBPATH) 64 @cp libmjollnir/libmjollnir.a $(LIBPATH) 65 @cp libmjollnir/libmjollnir.so $(LIBPATH) 66 # @cp e2dbg/e2dbg.so $(LIBPATH) 67 # @cp libui/libui.a libui/libui.so $(LIBPATH) 68 @cp -R libelfsh/include/* $(INCPATH) 69 @cp libasm/include/*.h $(INCPATH) 70 @cp libui/include/libui.h $(INCPATH) 71 @cp libc/include/elfsh-libc.h $(INCPATH) 72 @cp libmjollnir/include/libmjollnir*.h $(INCPATH) 73 # @cp doc/elfsh.1 $(MANPATH)/man1/ 74 # @chmod 755 $(MANPATH)/man1/elfsh.1 75 @chmod 755 $(BINPATH)/elfsh 76 # @chmod 755 $(BINPATH)/e2dbg 77 @chmod 755 $(LIBPATH)libelfsh.so 78 # @chmod 755 $(LIBPATH)e2dbg.so 79 @chmod 644 $(LIBPATH)libcelfsh.a 80 # @chmod 755 $(LIBPATH)libui.so 81 @chmod 644 $(LIBPATH)libui.a 82 @chmod 755 $(INCPATH)libui.h 83 @chmod 755 $(INCPATH)libelfsh*.h 84 @chmod 644 $(LIBPATH)libelfsh.a 85 @chmod 644 $(LIBPATH)libasm.a 86 @chmod 755 $(INCPATH)libelfsh*.h 87 @chmod 755 $(INCPATH)libasm*.h 88 89 prepareDir: 90 @mkdir -p $(DESTDIR) || true 91 @mkdir -p $(BINPATH) || true 92 @mkdir -p $(LIBPATH) || true 93 @mkdir -p $(INCPATH) || true 94 @mkdir -p $(MANPATH)/man1/ || true 95 @mkdir -p $(MODPATH) || true 96 @echo 'ELFsh, E2dbg, Libelfsh, Libmjollnir, Libui and Libasm installed successfully .' 97 98 mod_install: 99 @mkdir $(MODPATH) 2>/dev/null || true 100 @cp modules/*.so $(MODPATH) 101 @chmod -R 755 $(MODPATH) 102 103 uninstall: 104 rm -f $(BINPATH)/elfsh 105 rm -f $(BINPATH)/e2dbg 106 rm -f $(LIBPATH)/libelfsh* 107 rm -f $(LIBPATH)/e2dbg* 108 rm -f $(LIBPATH)/libui.so 109 rm -f $(LIBPATH)/libui.a 110 rm -f $(LIBPATH)/libmalloc-e2dbg.a 111 rm -f $(LIBPATH)/libcelfsh.a 112 rm -f $(LIBPATH)/libmjollnir.a 113 rm -f $(LIBPATH)/libmjollnir.so 114 rm -fr $(MODPATH) 115 rm -f $(MANPATH)/man1/elfsh.1 116 rm -f $(LIBPATH)/libasm.a 117 rm -f $(INCPATH)/libasm*.h 118 rm -f $(INCPATH)/libmjollnir*.h 119 rm -f $(INCPATH)/libui.h 120 rm -fr $(INCPATH)/libelfsh* 121 @echo 'ELFsh, Libelfsh, Libmjollnir, Libui and Libasm uninstalled successfully' 122 123 clean : cleandoc 124 @echo 'Cleaning tree ...' 125 cd vm && $(MAKE) -s clean 126 cd e2dbg && $(MAKE) -s clean 127 cd libelfsh && $(MAKE) -s clean 128 cd libc && $(MAKE) -s clean 129 cd libui && $(MAKE) -s clean 130 cd libmjollnir && $(MAKE) -s clean 131 cd libasm && $(MAKE) -s clean 132 cd libmalloc && $(MAKE) -s clean 133 cd libdump && $(MAKE) -s clean 134 cd modules && $(MAKE) -s clean 135 @echo 'Tree cleaned .' 136 137 fclean : cleandoc 138 @echo 'Fcleaning tree ...' 139 cd vm && $(MAKE) -s fclean 140 cd e2dbg && $(MAKE) -s fclean 141 cd libelfsh && $(MAKE) -s fclean 142 cd libc && $(MAKE) -s fclean 143 cd libasm && $(MAKE) -s fclean 144 cd libmalloc && $(MAKE) -s fclean 145 cd libmjollnir && $(MAKE) -s clean 146 cd libdump && $(MAKE) -s fclean 147 cd libui && $(MAKE) -s fclean 148 cd modules && $(MAKE) -s fclean 149 cd testsuite && $(MAKE) -s fclean 150 @echo 'Tree cleaned .' 151 152 cleandoc: 153 @rm -f *~ *\# \#* .\#* 154 @rm -f doc/*~ doc/*\# doc/\#* doc/.\#* 155 @rm -f doc/research/*~ doc/research/*\# 156 @rm -f doc/research/\#* doc/research/.\#* 157 158 tags : 159 @echo Doing tags ... 160 @$(ETAGS) vm/*.c vm/include/*.h libelfsh/*.c \ 161 libelfsh/include/*.h e2dbg/include/*.h \ 162 modules/*.c libmalloc/*.c libdump/*.c e2dbg/*.c \ 163 libasm/src/*.c libmalloc/include/*.h \ 164 libasm/src/arch/ia32/*.c libmjollnir/src/*.c \ 165 libasm/include/*.h libui/*.c libui/include/*.h \ 166 libdump/include/*.h libmjollnir/include/*.h \ 167 libc/include/*.h libc/*.c 168 169 info : 170 @echo '###############' Total '###############' 171 wc -l vm/*.c libelfsh/*.c libelfsh/include/*.h \ 172 vm/include/*.h modules/*.c libasm/src/*.c \ 173 libasm/src/arch/ia32/*.c e2dbg/*.c e2dbg/include/*.h 174 @echo '###############' Total w/o headers '###' 175 wc -l vm/*.c libelfsh/*.c modules/*.c e2dbg/*.c 176 @echo '###############' Libelfsh only '#######' 177 wc -l libelfsh/*.c 178 @echo '###############' Libasm only ##########' 179 wc -l libasm/src/*.c libasm/src/arch/ia32/*.c 180 @echo '###############' Libui only ##########' 181 wc -l libui/*.c 182 @echo '###############' VM only '#############' 183 wc -l vm/*.c 184 @echo '###############' E2DBG only '#############' 185 wc -l e2dbg/*.c 186 @echo '###############' Modules only '########' 187 wc -l modules/*.c 188 -
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/Makefile
diff -urN ./libelfsh/Makefile ../elfsh.mine/libelfsh/Makefile
old new 11 11 LD = gcc 12 12 RM = rm -f 13 13 AR = ar rc 14 CFLAGS += -Iinclude -Wall -fPIC -g 3 -O2-DELFSH_INTERN \14 CFLAGS += -Iinclude -Wall -fPIC -g -DELFSH_INTERN \ 15 15 -I../libasm/include/ -I../libc/include $(BITS) $(BUILDOP) 16 LDFLAGS = -L/boot/home/config/lib/ $(LPTHREAD)\ 17 -L../libc/ -L../libasm/ -lcelfsh -lasm 16 18 SRC = dynamic.c dynsym.c elf.c fixup.c got.c hash.c \ 17 19 interp.c pht.c plt.c section.c sht.c error.c stab.c \ 18 20 symbol.c notes.c reloc.c ctors.c dtors.c search.c \ … … 22 24 bss.c sort.c hooks.c ia32.c sparc32.c sparc64.c \ 23 25 mips32.c alpha64.c ia64.c mips64.c reginfo.c \ 24 26 altplt.c altgot.c extplt.c runtime.c state.c \ 25 inject.c linkmap.c bp.c libhash.c rpht.c version.c27 inject.c linkmap.c bp.c libhash.c rpht.c version.c 26 28 OBJ = $(SRC:.c=.o) 27 29 NAME = libelfsh 28 30 29 31 all : $(OBJ) 30 @$(LD) --trace-symbol=malloc -L../libc/ -lcelfsh -L../libmalloc/ -lmalloc-e2dbg\31 $(BITS) -shared $(OBJ) -o $(NAME).so32 @$(AR) $(NAME).a $(OBJ)33 @$(RANLIB) $(NAME).a32 $(LD) --trace-symbol=malloc \ 33 $(BITS) -shared $(OBJ) -o $(NAME).so $(LDFLAGS) 34 @$(AR) $(NAME).a $(OBJ) 35 @$(RANLIB) $(NAME).a 34 36 35 37 36 38 dumpregs.o: dumpregs.c 37 $(CC) $(CFLAGS) -fomit-frame-pointer $< -o $@ -c39 $(CC) $(CFLAGS) -fomit-frame-pointer $< -o $@ -c 38 40 39 41 40 42 clean : 41 @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\# \42 include/*~ include/.\#*43 @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\# \ 44 include/*~ include/.\#* 43 45 44 46 fclean : clean 45 @$(RM) $(NAME).so $(NAME).a47 @$(RM) $(NAME).so $(NAME).a 46 48 -
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/ia32.c
diff -urN ./libelfsh/ia32.c ../elfsh.mine/libelfsh/ia32.c
old new 390 390 elfshsect_t *mod) 391 391 { 392 392 elfsh_Shdr *section; 393 elfsh_Sym *symbol; 394 char *symname; 393 elfsh_Sym *symbol; 394 elfsh_Rel *rel_entry; 395 char *symname; 395 396 396 397 ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 397 398 … … 408 409 *dword = addr - (new->shdr->sh_addr + cur->r_offset + 4); 409 410 break; 410 411 412 /* offset from the start of the got */ 411 413 case R_386_GOT32: 412 414 section = elfsh_get_sht_entry_by_name(new->parent, ELFSH_SECTION_NAME_GOT); 413 415 if (section == NULL) 414 416 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 415 "Unable to find GOT for GOTOFF", -1); 416 *dword = cur->r_offset - section->sh_addr; 417 "Unable to find GOT for GOTOFF", -1); 418 419 symname = elfsh_get_symname_from_reloc(mod->parent, cur); 420 if(symname == NULL) 421 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 422 "Unable to find symbol in host", -1); 423 424 rel_entry = elfsh_get_relent_by_name(new->parent, symname); 425 if(rel_entry == NULL) 426 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 427 "Unable to find relocation in host", -1); 428 *dword = elfsh_get_reloffset(rel_entry) - section->sh_addr; 417 429 break; 418 430 419 431 case R_386_PLT32: … … 473 485 ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 474 486 "Unable to find GOT for GOTPC", -1); 475 487 476 *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2;488 *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 3; 477 489 478 490 #if __DEBUG_RELADD__ 479 491 printf("[DEBUG_RELADD] R_386_GOTPC : *dword=%08X, non added *dword was %08X \n", 480 section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2, *dword);492 section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 3, *dword); 481 493 #endif 482 494 483 495 break; -
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)
