Ticket #10: 9_beos_complete.diff
| File 9_beos_complete.diff, 40.6 kB (added by zadig, 39 years ago) |
|---|
-
README.BEOS
diff -urN ./README.BEOS ../elfsh.mine/README.BEOS
old new 1 2 ------------------- 3 ELFSH BeOS 4 ------------------- 5 6 Here are some information concerning elfsh compilation on BeOS systems. Please 7 read this text carefully to use elfsh on BeOS because if it can be compiled it 8 does not compile "out of the box" yet. Especially the modifications done work on 9 zeta. I suppose that these changes should work on a R5+bone system. 10 11 Several files are necessary that are not bundled here: 12 - A libpthread is required (base on haiku code). 13 - Some include files are needed. 14 15 To get these files you can ask on the elfsh irc channel. Moreover several parts 16 of the code are stil not commited on cvs, and others are not ported: 17 - liballocproxy is not ported yet. A stub has been written. 18 - e2dbg abd etrace are not ported. 19 20 To compile elfsh you should follow the foloowing steps: 21 22 ./configure --enable-32 --enable-readline --use-ctags --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\"" 23 24 In the generated Makefile, comment the generation of e2dbg, libe2dbg, etrace. 25 You may also have to fix the generated file in: 26 librevm/include/revm-vars.h 27 28 Then just type: 29 make 30 make install 31 -
configure
diff -urN ./configure ../elfsh.mine/configure
old new 309 309 echo "RANLIB = /usr/bin/true" >> $CONFIGFILE 310 310 ;; 311 311 312 BeOS*) 313 echo "#define BEOS 1" >> $LIBVARSFILE 314 echo "RANLIB = ranlib" >> $CONFIGFILE 315 BEOS="1"; 316 ;; 317 312 318 *) 313 319 314 320 if [ "$STATIC" = "0" ]; then … … 386 392 if [ "$FREEBSD" = "1" ]; then 387 393 echo "BASEPATH = \$(DESTDIR)/usr/local" >> Makefile 388 394 echo "MANPATH = \$(BASEPATH)/man" >> Makefile 395 elif [ "$BEOS" = "1" ]; then 396 echo "BASEPATH = \$(DESTDIR)" >> Makefile 397 echo "MANPATH = \$(BASEPATH)/share/man" >> Makefile 389 398 else 390 399 echo "BASEPATH = \$(DESTDIR)/usr/local" >> Makefile 391 400 echo "MANPATH = \$(BASEPATH)/share/man" >> Makefile -
doc/glob_shared.txt
diff -urN ./doc/glob_shared.txt ../elfsh.mine/doc/glob_shared.txt
old new 1 global symbols injection. 2 3 This document describes the injection process of global objects on beos systems. 4 The issues on this system should be the same on other os when injecting rel 5 objects in shared libraries. 6 7 This text is based on the etrel_original test of the elfsh testsuite. 8 9 1- Static objects. 10 11 the object will be located in rel.o.data: 12 13 relocation: 14 15 2- initialized objects 16 17 the object will be located in the data section (num 3): 18 17: 00000000 4 OBJECT GLOBAL DEFAULT 3 glvar_testreloc 19 20 a symbol injected should have the following specs: 21 98: 000025f0 4 OBJECT GLOBAL DEFAULT COM gi_global1 22 | 23 \|/ 24 got 25 26 relocation type is R_386_GOT32: 27 0000009c 00001103 R_386_GOT32 00000000 glvar_testreloc 28 29 Issue in 0.74: The relocation is not correct. The value points directly to 30 the global symbol address instead of its altgot entry. hence a crash when the 31 code try to access the content of the got entry that is in fact the actual 32 object value. 33 34 A new got entry must be allocated for this object in altgot, and the 35 relocation must be performed on it. 36 37 When should this entry be added ? 38 in extplt technique the entry is added when performing the relocation if we 39 do not find the symbol in the host/rel. In this case the symbol is present 40 but not its got entry. 41 42 So the following steps must be done: 43 - When allocated, the altgot rel section (.elfsh.reldyn) must be oversized to 44 add new entries. 45 - allocate a new got entry for the symbol. 46 - allocate a new relocation entry in elfsh.reldyn for this got entry. 47 48 3- uninitialized objects 49 50 the object will be located in rel.o.bss: -
e2dbg/include/libe2dbg.h
diff -urN ./e2dbg/include/libe2dbg.h ../elfsh.mine/e2dbg/include/libe2dbg.h
old new 14 14 #include "revm.h" 15 15 #include "aproxy.h" 16 16 17 #ifdef __BEOS__ 18 typedef char siginfo_t; 19 #define SA_SIGINFO NSIG 20 #define sa_sigaction sa_handler 21 #endif 22 17 23 #define __DEBUG_E2DBG__ 0 18 24 #define __DEBUG_MUTEX__ 1 19 25 #define __DEBUG_BP__ 0 -
elfsh/Makefile
diff -urN ./elfsh/Makefile ../elfsh.mine/elfsh/Makefile
old new 37 37 LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ 38 38 -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ 39 39 -lmjollnir32 $(LPTHREAD) -L../elibc -lcelfsh32 \ 40 -L/boot/home/config/lib $(LPTHREAD) \ 40 41 -L../libasm/ -lasm $(LDUIOPT32) -g3 \ 41 42 -L../liballocproxy -L../libmjollnir/ \ 42 43 -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ -
liballocproxy/Makefile
diff -urN ./liballocproxy/Makefile ../elfsh.mine/liballocproxy/Makefile
old new 10 10 11 11 CC ?= gcc 12 12 LD ?= ld 13 SRC = aproxy_malloc.c aproxy_strdup.c 13 SRC = elfsh_malloc_beos.c 14 #SRC = aproxy_malloc.c aproxy_strdup.c 14 15 OBJ = $(SRC:.c=.o) 15 16 CFLAGS += -D__STD_C -DMALLOC_DEBUG -DUSE_ARENAS -DSHARED -DUSE_TLS \ 16 17 -fPIC -g3 -Iinclude -I../libelfsh/include/ -
liballocproxy/elfsh_malloc_beos.c
diff -urN ./liballocproxy/elfsh_malloc_beos.c ../elfsh.mine/liballocproxy/elfsh_malloc_beos.c
old new 1 #include <stdio.h> 2 3 _EXPORT void *elfsh_calloc(size_t size, char val) 4 { 5 return(calloc(size, val)); 6 } 7 8 _EXPORT void *elfsh_realloc(void * addr, size_t size) 9 { 10 return(realloc(addr, size)); 11 } 12 13 _EXPORT void *elfsh_malloc(size_t size) 14 { 15 return(malloc(size)); 16 } 17 _EXPORT void *elfsh_valloc(size_t t) 18 { 19 return(valloc(t)); 20 } 21 22 _EXPORT void *elfsh_memalign(size_t t, u_int nbr) 23 { 24 return(memalign(t, nbr)); 25 } 26 27 _EXPORT void elfsh_free(void * addr) 28 { 29 free(addr); 30 } 31 -
libasm/include/libasm.h
diff -urN ./libasm/include/libasm.h ../elfsh.mine/libasm/include/libasm.h
old new 11 11 12 12 13 13 #include <sys/types.h> 14 #ifdef __BEOS__ 15 #include <stdint.h> 16 #endif 14 17 #include <stdio.h> 15 18 #include <string.h> 16 19 #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 15 15 */ 16 16 17 17 int i386_group12(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 18 struct s_modrm *modrm; 18 19 new->ptr_instr = opcode; 19 20 new->len += 1; 20 struct s_modrm *modrm = (struct s_modrm *) opcode + 1;21 modrm = (struct s_modrm *) opcode + 1; 21 22 22 23 switch (modrm->r) { 23 24 case 2: … … 67 68 */ 68 69 69 70 int i386_group14(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 71 struct s_modrm *modrm; 70 72 new->ptr_instr = opcode; 71 73 new->len += 1; 72 struct s_modrm *modrm = (struct s_modrm *) opcode + 1;74 modrm = (struct s_modrm *) opcode + 1; 73 75 74 76 switch (modrm->r) { 75 77 case 2: -
libasm/src/arch/ia32/handlers/i386_group12.c
diff -urN ./libasm/src/arch/ia32/handlers/i386_group12.c ../elfsh.mine/libasm/src/arch/ia32/handlers/i386_group12.c
old new 10 10 */ 11 11 12 12 int i386_group12(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 13 struct s_modrm *modrm; 13 14 new->ptr_instr = opcode; 14 15 new->len += 1; 15 struct s_modrm *modrm = (struct s_modrm *) opcode + 1;16 modrm = (struct s_modrm *) opcode + 1; 16 17 17 18 switch (modrm->r) { 18 19 case 2: -
libasm/src/arch/ia32/handlers/i386_group14.c
diff -urN ./libasm/src/arch/ia32/handlers/i386_group14.c ../elfsh.mine/libasm/src/arch/ia32/handlers/i386_group14.c
old new 10 10 */ 11 11 12 12 int i386_group14(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { 13 struct s_modrm *modrm; 13 14 new->ptr_instr = opcode; 14 15 new->len += 1; 15 struct s_modrm *modrm = (struct s_modrm *) opcode + 1;16 modrm = (struct s_modrm *) opcode + 1; 16 17 17 18 switch (modrm->r) { 18 19 case 2: -
libe2dbg/Makefile
diff -urN ./libe2dbg/Makefile ../elfsh.mine/libe2dbg/Makefile
old new 35 35 -I../libedfmt/include/ -I../liballocproxy/include/ \ 36 36 -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DELFSH64 37 37 38 LDFLAGS32 += $(DLOPT) $(LDMJOLLNIR) $(DYNOPT) $(EXTRAOPT) $(LDDUMPOPT) 39 LDFLAGS64 += $(DLOPT) $(LDMJOLLNIR) $(DYNOPT) $(EXTRAOPT) $(LDDUMPOPT) 38 LDFLAGS32 += $(DLOPT) $(LDMJOLLNIR) $(DYNOPT) $(EXTRAOPT) $(LDDUMPOPT) -L/boot/home/config/lib $(LPTHREAD) 39 LDFLAGS64 += $(DLOPT) $(LDMJOLLNIR) $(DYNOPT) $(EXTRAOPT) $(LDDUMPOPT) $(LPTHREAD) 40 40 41 41 EXTRAOBJ32 = ../libasm/libasm.o ../libmjollnir/libmjollnir32.o \ 42 42 ../libelfsh/libelfsh32.o ../libedfmt/libedfmt32.o \ -
libe2dbg/dumpregs.c
diff -urN ./libe2dbg/dumpregs.c ../elfsh.mine/libe2dbg/dumpregs.c
old new 46 46 47 47 #if defined(__amd64__) && defined(__FreeBSD__) 48 48 #error "Register context not filled on FreeBSD / AMD64" 49 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 49 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__BEOS__) 50 50 e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.mc_eax); 51 51 e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.mc_ebx); 52 52 e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.mc_ecx); -
libe2dbg/include/libe2dbg.h
diff -urN ./libe2dbg/include/libe2dbg.h ../elfsh.mine/libe2dbg/include/libe2dbg.h
old new 14 14 #include "revm.h" 15 15 #include "aproxy.h" 16 16 17 #ifdef __BEOS__ 18 /* TODO: this allow to compile but certainly not to run */ 19 typedef char siginfo_t; 20 #define SA_SIGINFO NSIG 21 #define SA_NODEFER 0 22 #define sa_sigaction sa_handler 23 #endif 24 17 25 #define __DEBUG_E2DBG__ 0 18 26 #define __DEBUG_BP__ 0 19 27 #define __DEBUG_EMALLOC__ 0 -
libe2dbg/xmalloc.c
diff -urN ./libe2dbg/xmalloc.c ../elfsh.mine/libe2dbg/xmalloc.c
old new 146 146 147 147 148 148 /* Wrapper for calloc */ 149 #if __FreeBSD__ > 5149 #if (__FreeBSD__ > 5) || defined(__BEOS__) 150 150 void *calloc(size_t t, size_t nbr) 151 151 #else 152 152 void *calloc(size_t t, u_int nbr) -
libedfmt/Makefile
diff -urN ./libedfmt/Makefile ../elfsh.mine/libedfmt/Makefile
old new 18 18 NAME32 = libedfmt32 19 19 NAME64 = libedfmt64 20 20 21 CFLAGS32 += -Wall -fPIC -g 3 -O2-Iinclude -I ../libaspect/include/ \21 CFLAGS32 += -Wall -fPIC -g -Iinclude -I ../libaspect/include/ \ 22 22 -I../libelfsh/include/ -I../elibc/include/ -DELFSH_INTERN \ 23 23 -DELFSH32 24 24 -
libedfmt/stabs.c
diff -urN ./libedfmt/stabs.c ../elfsh.mine/libedfmt/stabs.c
old new 219 219 220 220 PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); 221 221 222 if(current_file == NULL) 223 PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); 224 222 225 /* End of the current function ? */ 223 226 if (STABS_IVD_STR(str)) 224 227 { … … 281 284 282 285 if (NULL == type || STABS_IVD_STR(str)) 283 286 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 284 "Invalid parameter", NULL);287 "Invalid parameter", -1); 285 288 286 289 /* First we got a type */ 287 290 rtype = edfmt_stabs_type(str); … … 384 387 if (isVector) 385 388 type->u.arr.type |= STABS_ARRAY_VECTOR; 386 389 387 PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL);390 PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); 388 391 } 389 392 390 393 /** … … 1000 1003 case STABS_TYPE_BINCL: 1001 1004 inc = 1; 1002 1005 case STABS_TYPE_SO: 1006 if (!current_file) 1007 break; 1008 1003 1009 /* Include or SO file */ 1004 1010 parse_str = 0; 1005 1011 if (!inc && (!str || !str[0])) … … 1114 1120 { 1115 1121 data = STABS_DATA(&str); 1116 1122 1117 if (data )1123 if (data && current_file) 1118 1124 { 1119 1125 /* TODO: Add more informations */ 1120 1126 switch(data->scope) -
libelfsh/Makefile
diff -urN ./libelfsh/Makefile ../elfsh.mine/libelfsh/Makefile
old new 35 35 all : all32 all64 36 36 37 37 all32 : $(OBJ32) 38 @$(CC) -L../elibc/ -lcelfsh32 -L../liballocproxy/ \ 38 @$(CC) -shared $(OBJ32) -o $(NAME32).so \ 39 -L../elibc/ -lcelfsh32 -L../liballocproxy/ \ 39 40 -lallocproxy -L../libaspect/ -laspect32 -DELFSH32 \ 40 - shared $(OBJ32) -o $(NAME32).so41 -L../libasm/ -lasm 41 42 @$(AR) $(NAME32).a $(OBJ32) 42 43 @$(RANLIB) $(NAME32).a 43 44 @$(LD) -r $(OBJ32) -o $(NAME32).o -
libelfsh/bss.c
diff -urN ./libelfsh/bss.c ../elfsh.mine/libelfsh/bss.c
old new 335 335 if (elfsh_get_symbol_link(symtab + index) == SHN_COMMON) 336 336 { 337 337 338 /* Align symbol size as needed */339 if (symtab[index].st_value)340 while (bss_size % symtab[index].st_value)341 bss_size++;338 /* Align symbol size as needed */ 339 if (symtab[index].st_value) 340 while (bss_size % symtab[index].st_value) 341 bss_size++; 342 342 343 /* global symbols will added later in the injection process */ 344 if(elfsh_get_symbol_bind(symtab + index) == STB_LOCAL) 345 { 346 /* Create and inject symbol in ET_EXEC */ 347 new = elfsh_create_symbol(bss_size, 348 symtab[index].st_size, 349 STT_OBJECT, STB_LOCAL, 350 0, host_bss->index); 343 351 344 /* Create and inject symbol in ET_EXEC */ 345 new = elfsh_create_symbol(bss_size, 346 symtab[index].st_size, 347 STT_OBJECT, STB_LOCAL, 348 0, host_bss->index); 349 350 name = elfsh_get_symbol_name(rel, symtab + index); 351 elfsh_insert_symbol(host_symtab, &new, name); 352 bss_size += symtab[index].st_size; 352 name = elfsh_get_symbol_name(rel, symtab + index); 353 elfsh_insert_symbol(host_symtab, &new, name); 354 bss_size += symtab[index].st_size; 355 } 353 356 } 354 357 355 358 bss_size -= host_bss->shdr->sh_addr; -
libelfsh/extplt.c
diff -urN ./libelfsh/extplt.c ../elfsh.mine/libelfsh/extplt.c
old new 259 259 elfsh_set_dynentry_val(dynent, elfsh_get_dynentry_val(dynent) + relentsz); 260 260 261 261 /* Insert symbol referenced by previous injected reloc entry */ 262 sym = elfsh_create_symbol(extplt->shdr->sh_addr + extplt->curend - elfsh_get_pltentsz(file), 263 elfsh_get_pltentsz(file), STT_SECTION, 264 0, 0, extplt->index); 262 if(elfsh_get_ostype(file) == ELFSH_OS_BEOS) 263 { 264 sym = elfsh_create_symbol(extplt->shdr->sh_addr + extplt->curend - elfsh_get_pltentsz(file), 265 elfsh_get_pltentsz(file), STT_FUNC, 266 STB_GLOBAL, STV_DEFAULT, SHN_UNDEF); 267 } 268 else 269 { 270 sym = elfsh_create_symbol(extplt->shdr->sh_addr + extplt->curend - elfsh_get_pltentsz(file), 271 elfsh_get_pltentsz(file), STT_SECTION, 272 0, 0, extplt->index); 273 } 265 274 sym.st_name = dynstr->curend; 266 275 elfsh_set_symbol_bind(&sym, STB_GLOBAL); 267 276 memcpy(elfsh_get_raw(dynsym) + dynsym->curend, &sym, sizeof(sym)); -
libelfsh/got.c
diff -urN ./libelfsh/got.c ../elfsh.mine/libelfsh/got.c
old new 454 454 PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); 455 455 } 456 456 457 458 459 460 /**461 * Only used on BeoS462 * Tested and developed by zadig@myrealbox.com463 *464 */465 int elfsh_get_got_symbol_reloc(elfshobj_t *file,466 uint8 *name,467 elfsh_Rel *rel_entry)468 {469 elfshsect_t *got, *rel_got;470 u_int index, got_rel_index;471 u_int entsz;472 int got_index;473 elfsh_Off off;474 void *data;475 476 PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);477 478 /* Sanity checks */479 entsz = elfsh_get_pltentsz(file);480 if (entsz < 0)481 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,482 "Invalid PLT entry size", -1);483 484 if (NULL == elfsh_get_dynsymtab(file, NULL))485 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,486 "Unable to get DYNSYM", -1);487 488 if (NULL == elfsh_get_symtab(file, NULL))489 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,490 "Unable to get SYMTAB", -1);491 492 /* get got section index */493 got = elfsh_get_section_by_name(file,494 ELFSH_SECTION_NAME_GOT,495 &got_index, NULL, NULL);496 if (got == NULL)497 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,498 "Unable to get GOT", -1);499 500 /* search the got relocation section */501 rel_got = NULL;502 for (got_rel_index = 0; got_rel_index < file->hdr->e_shnum; got_rel_index++)503 {504 rel_got = elfsh_get_section_by_index(file, got_rel_index,505 NULL, NULL);506 if (rel_got->shdr->sh_info == got_index)507 break;508 }509 510 if ((rel_got == NULL) || (rel_got->shdr->sh_info != got_index))511 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,512 "Unable to get GOT relocations", -1);513 514 /* search for the requested symbol */515 off = entsz;516 data = elfsh_get_raw(rel_got);517 for (index = 0;518 index < (rel_got->shdr->sh_size / rel_got->shdr->sh_entsize);519 off += entsz, index ++)520 {521 elfsh_Rel *cur_rel;522 cur_rel = ((elfsh_Rel*) data) + index;523 if(strcmp(elfsh_get_symname_from_reloc(file, cur_rel), name) == 0)524 {525 *rel_entry = *cur_rel;526 PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);527 }528 }529 530 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,531 "Symbol not found", -1);532 }533 534 535 536 -
libelfsh/hooks.c
diff -urN ./libelfsh/hooks.c ../elfsh.mine/libelfsh/hooks.c
old new 842 842 ELFSH_OS_SOLARIS, elfsh_cflow_mips64); 843 843 elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 844 844 ELFSH_OS_LINUX, elfsh_cflow_ia32); 845 elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 846 ELFSH_OS_BEOS, elfsh_cflow_ia32); 845 847 846 848 /* Usual REL/PLT/ALTPLT targets for ET_DYN/x86 */ 847 849 elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, … … 854 856 ELFSH_OS_NETBSD, elfsh_hijack_plt_ia32); 855 857 elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 856 858 ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia32); 859 elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 860 ELFSH_OS_BEOS, elfsh_hijack_plt_ia32); 857 861 elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 858 862 ELFSH_OS_BEOS, elfsh_relocate_ia32); 859 863 elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, … … 915 919 ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); 916 920 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 917 921 ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); 922 elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 923 ELFSH_OS_BEOS, elfsh_encodeplt_ia32); 918 924 919 925 /* Usual ENCODEPLT1 targets for ET_EXEC/IA32 */ 920 926 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, … … 937 943 ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); 938 944 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 939 945 ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); 946 elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 947 ELFSH_OS_BEOS, elfsh_encodeplt1_ia32); 940 948 941 949 /*** Now EXTPLT handlers ***/ 942 950 … … 961 969 ELFSH_OS_OPENBSD, elfsh_extplt_ia32); 962 970 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 963 971 ELFSH_OS_SOLARIS, elfsh_extplt_ia32); 972 elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, 973 ELFSH_OS_BEOS, elfsh_extplt_ia32); 964 974 965 975 /***************************************/ 966 976 /****** ARGC arguments counting ******/ -
libelfsh/ia32.c
diff -urN ./libelfsh/ia32.c ../elfsh.mine/libelfsh/ia32.c
old new 416 416 { 417 417 elfsh_Shdr *section; 418 418 elfsh_Sym *symbol; 419 elfsh_Rel *rel_entry; 419 420 char *symname; 420 421 421 422 PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); … … 438 439 if (section == NULL) 439 440 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 440 441 "Unable to find GOT for GOTOFF", -1); 441 *dword = cur->r_offset - section->sh_addr; 442 symname = elfsh_get_symname_from_reloc(mod->parent, cur); 443 if(symname == NULL) 444 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 445 "Unable to find symbol in host", -1); 446 447 rel_entry = elfsh_get_relent_by_name(new->parent, symname); 448 if(rel_entry == NULL) 449 *dword = addr - section->sh_addr; 450 else 451 *dword = elfsh_get_reloffset(rel_entry) - section->sh_addr; 442 452 break; 443 453 444 454 case R_386_PLT32: … … 497 507 if (section == NULL) 498 508 PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 499 509 "Unable to find GOT for GOTPC", -1); 500 501 *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2; 510 if(elfsh_get_ostype(new->parent) == ELFSH_OS_BEOS) 511 *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 3; 512 else 513 *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2; 502 514 503 515 #if __DEBUG_RELADD__ 504 printf("[DEBUG_RELADD] R_386_GOTPC : *dword=%08X, non added *dword was %08X \n", 505 section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2, *dword); 516 if(elfsh_get_ostype(new->parent) == ELFSH_OS_BEOS) 517 { 518 printf("[DEBUG_RELADD] R_386_GOTPC : *dword=%08X, non added *dword was %08X \n", 519 section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 3, *dword); 520 } 521 else 522 { 523 printf("[DEBUG_RELADD] R_386_GOTPC : *dword=%08X, non added *dword was %08X \n", 524 section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2, *dword); 525 } 506 526 #endif 507 527 508 528 break; -
libelfsh/include/libelfsh.h
diff -urN ./libelfsh/include/libelfsh.h ../elfsh.mine/libelfsh/include/libelfsh.h
old new 22 22 #include <fcntl.h> 23 23 #include <errno.h> 24 24 #include <sys/stat.h> 25 #ifndef __BEOS__ 25 26 #include <sys/mman.h> 27 #endif 26 28 27 29 #include "elfsh-libc.h" 28 30 #include <elf.h> … … 30 32 #include <libelfsh/libelfsh-compat.h> 31 33 32 34 #ifdef __BEOS__ 35 #include <inttypes.h> 36 #include <stdint.h> 33 37 #include <bsd_mem.h> 38 #include <OS.h> 34 39 #endif 35 40 36 41 #if !defined(__USE_GNU) … … 39 44 40 45 #include <sys/ucontext.h> 41 46 47 #ifndef __BEOS__ 42 48 #include <sys/user.h> 43 49 #include <sys/procfs.h> 50 #endif 44 51 45 52 /* Configure the DEBUG modes for various part of the code */ 46 53 #define __DEBUG_MAP__ 0 -
libelfsh/mips32.c
diff -urN ./libelfsh/mips32.c ../elfsh.mine/libelfsh/mips32.c
