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 
     8include ./config.h  
     9  
     10CC      = gcc  
     11RM      = rm -f  
     12ETAGS   = etags  
     13CTAGS   = ctags  
     14DESTDIR = "/boot/home/config" 
     15BASEPATH = $(DESTDIR) 
     16MANPATH = $(BASEPATH)/share/man 
     17MODPATH = $(BASEPATH)/share/elfsh/ 
     18BINPATH = $(BASEPATH)/bin/ 
     19LIBPATH = $(BASEPATH)/lib/ 
     20INCPATH = $(BASEPATH)/include/ 
     21RM      = rm -f  
     22  
     23all     : world modules tags 
     24world   :  
     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  
     52modules:  
     53        @echo 'Building ELFsh modules suite...'  
     54        @cd modules && $(MAKE)  
     55        @echo 'ELFsh modules suite built successfully.'  
     56  
     57install : 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  
     89prepareDir:  
     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  
     98mod_install:  
     99        @mkdir $(MODPATH) 2>/dev/null || true  
     100        @cp modules/*.so $(MODPATH)  
     101        @chmod -R 755 $(MODPATH)  
     102  
     103uninstall:  
     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  
     123clean   : 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  
     137fclean  : 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  
     152cleandoc:  
     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  
     158tags    :  
     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  
     169info    :  
     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 
     3config.h: 
     4remove -rdynamic 
     5 
     6export RANLIB="ranlib" 
     7 
     8Makefile: 
     9BASEPATH = $(DESTDIR) 
     10   comment libmalloc, e2dbg 
     11 
  • e2dbg/dumpregs.c

    diff -urN ./e2dbg/dumpregs.c ../elfsh.mine/e2dbg/dumpregs.c
    old new  
    4141 
    4242#if defined(__amd64__) && defined(__FreeBSD__) 
    4343 
    44 #elif defined(__FreeBSD__) 
     44#elif defined(__FreeBSD__) || defined(__BEOS__) 
    4545  vm_dumpreg("EAX", e2dbgworld.curthread->context->uc_mcontext.mc_eax); 
    4646  vm_dumpreg("EBX", e2dbgworld.curthread->context->uc_mcontext.mc_ebx); 
    4747  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  
    99#ifndef __E2DBG_H__ 
    1010 #define __E2DBG_H__ 
    1111 
     12#ifdef __BEOS__ 
     13typedef char siginfo_t; 
     14#define SA_SIGINFO NSIG 
     15#define sa_sigaction sa_handler 
     16#endif 
     17 
    1218#define         __DEBUG_E2DBG__         0 
    1319#define         __DEBUG_MUTEX__         1 
    1420#define         __DEBUG_BP__            0 
  • e2dbg/xmalloc.c

    diff -urN ./e2dbg/xmalloc.c ../elfsh.mine/e2dbg/xmalloc.c
    old new  
    149149 
    150150 
    151151/* Wrapper for calloc */ 
    152 #if __FreeBSD__ > 5 
     152#if (__FreeBSD__ > 5) || defined(__BEOS__) 
    153153void            *calloc(size_t t, size_t nbr) 
    154154#else 
    155155void            *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  
    1010 
    1111 
    1212#include <sys/types.h> 
     13#ifdef __BEOS__ 
     14#include <stdint.h> 
     15#endif 
    1316#include <stdio.h> 
    1417#include <string.h> 
    1518#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  
    1212 */ 
    1313 
    1414int     i386_group12(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 
     15  struct s_modrm *modrm = (struct s_modrm *) opcode + 1; 
    1516  new->ptr_instr = opcode; 
    1617  new->len += 1; 
    17   struct s_modrm *modrm = (struct s_modrm *) opcode + 1; 
    1818   
    1919  switch (modrm->r) { 
    2020    case 2: 
     
    6464 */ 
    6565 
    6666int     i386_group14(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 
     67  struct s_modrm *modrm = (struct s_modrm *) opcode + 1; 
    6768  new->ptr_instr = opcode; 
    6869  new->len += 1; 
    69   struct s_modrm *modrm = (struct s_modrm *) opcode + 1; 
    7070   
    7171  switch (modrm->r) { 
    7272    case 2: 
  • libelfsh/Makefile

    diff -urN ./libelfsh/Makefile ../elfsh.mine/libelfsh/Makefile
    old new  
    1111LD                      = gcc 
    1212RM                      = rm -f  
    1313AR                      = ar rc 
    14 CFLAGS                  += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN      \ 
     14CFLAGS                  += -Iinclude -Wall -fPIC -g -DELFSH_INTERN      \ 
    1515                        -I../libasm/include/ -I../libc/include $(BITS) $(BUILDOP)  
     16LDFLAGS  =              -L/boot/home/config/lib/ $(LPTHREAD)\ 
     17                        -L../libc/ -L../libasm/ -lcelfsh -lasm  
    1618SRC                     = dynamic.c dynsym.c elf.c fixup.c got.c hash.c     \ 
    1719                        interp.c pht.c plt.c section.c sht.c error.c stab.c \ 
    1820                        symbol.c notes.c reloc.c ctors.c dtors.c search.c   \ 
     
    2224                        bss.c sort.c hooks.c ia32.c sparc32.c sparc64.c     \ 
    2325                        mips32.c alpha64.c ia64.c mips64.c reginfo.c        \ 
    2426                        altplt.c altgot.c extplt.c runtime.c state.c        \ 
    25                         inject.c linkmap.c bp.c libhash.c rpht.c version.c 
     27                inject.c linkmap.c bp.c libhash.c rpht.c version.c 
    2628OBJ                     = $(SRC:.c=.o) 
    2729NAME                    = libelfsh 
    2830 
    2931all                     : $(OBJ) 
    30                         @$(LD) --trace-symbol=malloc -L../libc/ -lcelfsh -L../libmalloc/ -lmalloc-e2dbg \ 
    31                         $(BITS) -shared $(OBJ) -o $(NAME).so 
    32                         @$(AR) $(NAME).a $(OBJ) 
    33                         @$(RANLIB) $(NAME).a 
     32                $(LD) --trace-symbol=malloc \ 
     33                $(BITS) -shared $(OBJ) -o $(NAME).so $(LDFLAGS) 
     34                @$(AR) $(NAME).a $(OBJ) 
     35                @$(RANLIB) $(NAME).a 
    3436 
    3537 
    3638dumpregs.o:             dumpregs.c 
    37                         $(CC) $(CFLAGS) -fomit-frame-pointer $< -o $@ -c 
     39                $(CC) $(CFLAGS) -fomit-frame-pointer $< -o $@ -c 
    3840 
    3941 
    4042clean                   :  
    41                         @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\#  \ 
    42                         include/*~ include/.\#* 
     43                @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\#  \ 
     44                include/*~ include/.\#* 
    4345 
    4446fclean                  : clean 
    45                         @$(RM) $(NAME).so $(NAME).a 
     47                @$(RM) $(NAME).so $(NAME).a 
    4648 
  • libelfsh/got.c

    diff -urN ./libelfsh/got.c ../elfsh.mine/libelfsh/got.c
    old new  
    420420 
    421421 
    422422 
    423  
    424 /* 
    425 ** Only used on BeoS  
    426 ** Tested and developed by zadig@myrealbox.com 
    427 ** 
    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  
    641641                         ELFSH_OS_OPENBSD, elfsh_hijack_plt_ia32); 
    642642  elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    643643                         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); 
    644646   
    645647  /* Usual PLT targets for ET_EXEC/Sparc32 */ 
    646648  elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC,  
     
    729731                            ELFSH_OS_OPENBSD, elfsh_void_altplthandler); 
    730732  elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    731733                            ELFSH_OS_SOLARIS, elfsh_void_altplthandler); 
     734  elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     735                            ELFSH_OS_BEOS, elfsh_void_altplthandler); 
    732736   
    733737  /* Usual ALTPLT targets for ET_EXEC/Sparc32 */ 
    734738  elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC,  
     
    818822                         ELFSH_OS_OPENBSD, elfsh_relocate_ia32); 
    819823  elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    820824                         ELFSH_OS_SOLARIS, elfsh_relocate_ia32); 
     825  elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     826                         ELFSH_OS_BEOS, elfsh_relocate_ia32); 
    821827   
    822828  /* Usual REL targets for ET_EXEC/Sparc32 */ 
    823829  elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC,  
     
    906912                           ELFSH_OS_OPENBSD, elfsh_cflow_ia32); 
    907913  elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    908914                           ELFSH_OS_SOLARIS, elfsh_cflow_ia32); 
     915  elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     916                           ELFSH_OS_BEOS, elfsh_cflow_ia32); 
    909917 
    910918  /* Usual CFLOW targets for ET_EXEC/IA64 */ 
    911919  elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC,  
     
    980988                           ELFSH_OS_SOLARIS, elfsh_cflow_mips64); 
    981989  elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    982990                           ELFSH_OS_LINUX, elfsh_cflow_ia32); 
     991  elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     992                           ELFSH_OS_BEOS, elfsh_cflow_ia32); 
    983993 
    984994  /* Usual REL/PLT/ALTPLT targets for ET_DYN/x86 */ 
    985995  elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     
    10431053                               ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); 
    10441054  elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    10451055                               ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); 
     1056  elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     1057                               ELFSH_OS_BEOS, elfsh_encodeplt_ia32); 
    10461058  elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    10471059                               ELFSH_OS_LINUX, elfsh_encodeplt_ia32); 
    10481060  elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     
    10531065                               ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); 
    10541066  elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    10551067                               ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); 
     1068  elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     1069                               ELFSH_OS_BEOS, elfsh_encodeplt_ia32); 
    10561070 
    10571071  /* Usual ENCODEPLT1 targets for ET_EXEC/IA32 */ 
    10581072  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     
    10651079                                ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); 
    10661080  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    10671081                                ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); 
     1082  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     1083                                ELFSH_OS_BEOS, elfsh_encodeplt1_ia32); 
    10681084  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    10691085                                ELFSH_OS_LINUX, elfsh_encodeplt1_ia32); 
    10701086  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     
    10751091                                ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); 
    10761092  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    10771093                                ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); 
     1094  elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     1095                                ELFSH_OS_BEOS, elfsh_encodeplt1_ia32); 
    10781096 
    10791097  /*** Now EXTPLT handlers ***/ 
    10801098 
     
    10891107                            ELFSH_OS_OPENBSD, elfsh_extplt_ia32); 
    10901108  elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
    10911109                            ELFSH_OS_SOLARIS, elfsh_extplt_ia32); 
     1110  elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC,  
     1111                            ELFSH_OS_BEOS, elfsh_extplt_ia32); 
    10921112  elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    10931113                            ELFSH_OS_LINUX, elfsh_extplt_ia32); 
    10941114  elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     
    10991119                            ELFSH_OS_OPENBSD, elfsh_extplt_ia32); 
    11001120  elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
    11011121                            ELFSH_OS_SOLARIS, elfsh_extplt_ia32); 
     1122  elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN,  
     1123                            ELFSH_OS_BEOS, elfsh_extplt_ia32); 
    11021124 
    11031125  /***************************************/ 
    11041126  /****** ARGC arguments counting  ******/ 
  • libelfsh/ia32.c

    diff -urN ./libelfsh/ia32.c ../elfsh.mine/libelfsh/ia32.c
    old new  
    390390                             elfshsect_t        *mod) 
    391391{ 
    392392  elfsh_Shdr *section; 
    393   elfsh_Sym  *symbol;    
    394   char       *symname; 
     393  elfsh_Sym  *symbol; 
     394  elfsh_Rel  *rel_entry; 
     395  char      *symname; 
    395396 
    396397  ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); 
    397398    
     
    408409      *dword = addr - (new->shdr->sh_addr + cur->r_offset + 4); 
    409410      break; 
    410411 
     412      /* offset from the start of the got */ 
    411413    case R_386_GOT32:    
    412414      section = elfsh_get_sht_entry_by_name(new->parent, ELFSH_SECTION_NAME_GOT); 
    413415      if (section == NULL) 
    414416         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; 
    417429      break; 
    418430     
    419431    case R_386_PLT32: 
     
    473485         ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, 
    474486                        "Unable to find GOT for GOTPC", -1); 
    475487 
    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; 
    477489 
    478490#if     __DEBUG_RELADD__         
    479491      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); 
    481493#endif 
    482494 
    483495      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  
    1414 #define                ELFSH_ERR_ARRAY         sys_errlist[sys_nerr] 
    1515#endif 
    1616 
     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 
    1728/* Some calls defined in libmalloc */ 
    1829void            *elfsh_calloc(size_t, char); 
    1930void            *elfsh_realloc(void *, size_t); 
     
    2233void            *elfsh_memalign(size_t t, u_int nbr); 
    2334void            elfsh_free(void *); 
    2435void            __elfsh_libc_malloc_pthread_startup(int first_time); 
     36#endif 
    2537 
    2638/* Safe calloc() */ 
    2739#define         XALLOC(a, b, c)                                                                 \ 
  • libelfsh/include/libelfsh.h

    diff -urN ./libelfsh/include/libelfsh.h ../elfsh.mine/libelfsh/include/libelfsh.h
    old new  
    1818#include <fcntl.h> 
    1919#include <errno.h> 
    2020#include <sys/stat.h> 
     21#ifndef __BEOS__ 
    2122#include <sys/mman.h> 
     23#endif 
    2224 
    2325 
    2426#include "elfsh-libc.h" 
     
    2830#include <libelfsh/libelfsh-compat.h> 
    2931 
    3032#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> 
    3238#endif 
    3339 
    3440 
     
    865871u_int           elfsh_set_got_val(elfsh_Addr *got, elfsh_Addr val); 
    866872elfsh_Addr      elfsh_get_got_addr(elfsh_Addr *got); 
    867873u_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); 
    870874int             elfsh_endianize_got(elfshsect_t *_new); 
    871875elfshsect_t     *elfsh_get_gotsct(elfshobj_t *file); 
    872876int             elfsh_shift_got(elfshobj_t *file, u_int size); 
  • libelfsh/mips32.c

    diff -urN ./libelfsh/mips32.c ../elfsh.mine/libelfsh/mips32.c
    old new  
    509509                 GP = GP 
    510510              */ 
    511511              *HI16_dword +=  
    512                 VERIFY16((((old_HI16_dword << 16) + (short) A) +                /* AHL */ 
     512                VERIFY16((elfsh_Addr)(((old_HI16_dword << 16) + (short) A) +            /* AHL */ 
    513513                          GP -                                                  /* GP */ 
    514514                          (new->shdr->sh_addr + HI16_cur->r_offset) -           /* P */ 
    515515                          (short) (((old_HI16_dword << 16) + (short) A) +       /* AHL */ 
     
    539539       
    540540      if (ISGPDISP(cur)) 
    541541        { 
    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); 
    543543          ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); 
    544544        } 
    545545       
  • libelfsh/plt.c

    diff -urN ./libelfsh/plt.c ../elfsh.mine/libelfsh/plt.c
    old new  
    7979 
    8080  if (sym->st_size != file->secthash[ELFSH_SECTION_PLT]->shdr->sh_size)