From 955d3334eda909b1dba213638e0d44ea3ea00420 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 30 Sep 2005 09:50:51 +0000 Subject: [PATCH] * Use a real programming language. --- configure.ac | 2 ++ src/Makefile.am | 2 +- src/{patchelf.c => patchelf.cc} | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) rename src/{patchelf.c => patchelf.cc} (98%) diff --git a/configure.ac b/configure.ac index 71f2489..1ad50cc 100644 --- a/configure.ac +++ b/configure.ac @@ -16,5 +16,7 @@ if test "$STABLE" != "1"; then fi AC_PROG_CC +AC_PROG_CXX + AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index d61eee2..0bf1f83 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,3 @@ bin_PROGRAMS = patchelf -patchelf_SOURCES = patchelf.c +patchelf_SOURCES = patchelf.cc diff --git a/src/patchelf.c b/src/patchelf.cc similarity index 98% rename from src/patchelf.c rename to src/patchelf.cc index a957aa1..d0a5a2c 100644 --- a/src/patchelf.c +++ b/src/patchelf.cc @@ -65,7 +65,7 @@ static void readFile(char * fileName, mode_t * fileMode) *fileMode = st.st_mode; maxSize = fileSize + 128 * 1024; - contents = malloc(fileSize + maxSize); + contents = (unsigned char *) malloc(fileSize + maxSize); if (!contents) abort(); int fd = open(fileName, O_RDONLY); @@ -169,7 +169,7 @@ static void setInterpreter(void) growFile(phdr->p_offset + interpSize); phdr->p_vaddr = phdr->p_paddr = firstPage + interpOffset % 4096; phdr->p_filesz = phdr->p_memsz = interpSize; - strncpy(contents + interpOffset, + strncpy((char *) contents + interpOffset, newInterpreter, interpSize); changed = 1; break; @@ -219,7 +219,7 @@ static void shrinkRPath(void) if (phdrs[i].p_vaddr <= strTabAddr && strTabAddr < phdrs[i].p_vaddr + phdrs[i].p_filesz) { - strTab = contents + + strTab = (char *) contents + strTabAddr - phdrs[i].p_vaddr + phdrs[i].p_offset; } @@ -257,7 +257,7 @@ static void shrinkRPath(void) for (i = 0; i < nrNeededLibs; ++i) neededLibFound[i] = 0; - char * newRPath = malloc(strlen(rpath) + 1); + char * newRPath = (char *) malloc(strlen(rpath) + 1); *newRPath = 0; char * pos = rpath;