I was not convinced by the previous patch, since it did not work in amd64, so I studied the code a bit and discovered that <sys/ucontext.h> was already been included in elfsh.h.
Also, the _USE_GNU__ was not taking efect, because it was being undefined by features.h. By using _GNU_SOURCE instead, _USE_GNU__ gets defined appropiately. The sideeffect of this is that the dprintf function in stdio.h gets declared, whereas it was not being declared before, due to _GNO_SOURCE not being set. I'm not sure why upstream was declaring their own dprintf, but commenting that out works fine. I'm attaching a dpatch enabled version of this patch. However, this patch still does not make the code compile in amd64. The problem is inherent to what the module does (dump the registers), because the registers are called differently in amd64 (and I suspect they'll be called different in almost all of the other Debian architectures). I don't know what would be the real solution... Maybe making that function depend on the target architecture. Maybe use the enumeration of registers instead of calling them by name... The new elfsh seems to target mainly i386, even though they say it works in alpha, mips and sparc. I'm not sure what would be the best way to deal with this. -- Love, Marga.
#! /bin/sh /usr/share/dpatch/dpatch-run ## gnu_source.dpatch by Margarita Manterola <[EMAIL PROTECTED]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: define _GNU_SOURCE so that USE_GNU gets defined, comment out the ## dprintf call, so that it's not duplicated. @DPATCH@ diff -urNad elfsh-0.65rc1~/vm/include/elfsh.h elfsh-0.65rc1/vm/include/elfsh.h --- elfsh-0.65rc1~/vm/include/elfsh.h 2006-08-15 15:17:12.000000000 -0300 +++ elfsh-0.65rc1/vm/include/elfsh.h 2006-08-15 15:17:17.000000000 -0300 @@ -9,6 +9,8 @@ /* User defined configuration */ #include "../../vars.h" +#define _GNU_SOURCE 1 + #include <sys/types.h> #include <stdio.h> #include <termios.h> @@ -36,7 +38,6 @@ #include <dirent.h> -#define __USE_GNU #include <sys/ucontext.h> #ifdef __BEOS__ @@ -842,7 +843,7 @@ void vm_load_cwfiles(); int vm_implicit(elfshcmd_t *actual); int vm_unload_cwfiles(); -int dprintf(int fd, char *format, ...); +//int dprintf(int fd, char *format, ...); void vm_print_pht(elfsh_Phdr *phdr, uint16_t num, elfsh_Addr base); int vm_load_file(char *name, elfsh_Addr base, elfshlinkmap_t *lm); int vm_is_loaded(char *name);