1 --- a/configure.ac 2004-09-19 10:28:33.000000000 +0200
2 +++ b/configure.ac 2006-02-27 16:12:00.282066250 +0100
4 dnl Checks for programs.
9 dnl Checks for libraries.
12 dnl Checks for typedefs, structures, and compiler characteristics.
15 -AC_CHECK_SIZEOF(void *)
17 dnl Checks for library functions.
18 AC_CHECK_FUNCS(getopt_long)
19 --- a/Makefile.am 2004-09-19 10:29:28.000000000 +0200
20 +++ b/Makefile.am 2006-02-27 16:57:31.166290750 +0100
22 fakeroot debian/rules binary
33 +lib_LTLIBRARIES = libchrpath32.la libchrpath64.la
34 +libchrpath32_la_SOURCES = chrpath.c killrpath.c elf.c protos.h
35 +libchrpath32_la_CFLAGS = -DSIZEOF_VOID_P=4
36 +libchrpath32_la_LDFLAGS = -avoid-version
37 +libchrpath64_la_SOURCES = chrpath.c killrpath.c elf.c protos.h
38 +libchrpath64_la_CFLAGS = -DSIZEOF_VOID_P=8
39 +libchrpath64_la_LDFLAGS = -avoid-version
41 EXTRA_DIST = $(man_MANS)
43 CLEANFILES = *.bb *.bbg *.da *.gcov testsuite/*.bb testsuite/*.bbg
44 --- a/main.c 2004-09-19 10:33:37.000000000 +0200
45 +++ b/main.c 2006-02-27 17:23:39.400267750 +0100
62 +typedef int (*killrpath_t)(const char *filename);
63 +typedef int (*chrpath_t)(const char *filename, const char *newpath, int convert);
65 #ifdef HAVE_GETOPT_LONG
66 # define GETOPT_LONG getopt_long
72 +elf_class(const char *filename)
77 + fd = open(filename, O_RDONLY);
80 + if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
86 + if ((memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0)
87 + || (ehdr.e_ident[EI_VERSION] != EV_CURRENT))
89 + fprintf(stderr, "`%s' probably isn't an ELF file.\n", filename);
92 + return ehdr.e_ident[EI_CLASS];
96 main(int argc, char * const argv[])
99 #ifdef HAVE_GETOPT_LONG
100 int option_index = 0;
101 #endif /* HAVE_GETOPT_LONG */
103 + killrpath_t killrpath[2];
104 + chrpath_t chrpath[2];
108 @@ -116,14 +149,31 @@
112 + dll[0] = dlopen("libchrpath32.so", RTLD_LAZY);
113 + killrpath[0] = (killrpath_t)dlsym(dll[0], "killrpath");
114 + chrpath[0] = (chrpath_t)dlsym(dll[0], "chrpath");
116 + dll[1] = dlopen("libchrpath64.so", RTLD_LAZY);
117 + killrpath[1] = (killrpath_t)dlsym(dll[1], "killrpath");
118 + chrpath[1] = (chrpath_t)dlsym(dll[1], "chrpath");
120 while (optind < argc && (!retval || keep_going))
122 + const char* program = argv[optind++];
123 + unsigned eclass = elf_class(program);
130 - retval |= killrpath(argv[optind++]);
131 + retval |= killrpath[eclass - ELFCLASS32](program);
133 /* list by default, replace if path is set */
134 - retval |= chrpath(argv[optind++], newpath, convert);
135 + retval |= chrpath[eclass - ELFCLASS32](program, newpath, convert);