diff options
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/patchelf.cc | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/plain-needed.sh | 4 |
5 files changed, 15 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index c2e5e98..e762e1e 100644 --- a/configure.ac +++ b/configure.ac @@ -24,5 +24,10 @@ fi AC_DEFINE_UNQUOTED(PAGESIZE, ${PAGESIZE}) AC_MSG_RESULT([Setting page size to ${PAGESIZE}]) +AC_ARG_WITH([asan], + AS_HELP_STRING([--with-asan], [Link with libasan]) +) +AM_CONDITIONAL([WITH_ASAN], [test x"$with_asan" = xyes]) + AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 7170cf3..b9aee08 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,9 @@ AM_CXXFLAGS = -Wall -std=c++11 -D_FILE_OFFSET_BITS=64 +if WITH_ASAN +AM_CXXFLAGS += -fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1 +endif + bin_PROGRAMS = patchelf patchelf_SOURCES = patchelf.cc elf.h diff --git a/src/patchelf.cc b/src/patchelf.cc index 965686a..0d0f369 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -250,7 +250,6 @@ I ElfFile<ElfFileParamNames>::rdi(I i) return r; } - /* Ugly: used to erase DT_RUNPATH when using --force-rpath. */ #define DT_IGNORE 0x00726e67 @@ -737,7 +736,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary() ET_DYN as does LD when linking with pie. If we move PT_PHDR, it has to stay in the first PT_LOAD segment or any subsequent ones if they're continuous in memory due to linux kernel constraints - (see BUGS). Since the end of the file would be after bss, we can't + (see BUGS). Since the end of the file would be after bss, we can't move PHDR there, we therefore choose to leave PT_PHDR where it is but move enough following sections such that we can add the extra PT_LOAD section to it. This PT_LOAD segment ensures the sections at the end of diff --git a/tests/Makefile.am b/tests/Makefile.am index 96339b3..d2d58b0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,6 +23,7 @@ src_TESTS = \ set-interpreter-long.sh set-rpath.sh no-rpath.sh big-dynstr.sh \ set-rpath-library.sh soname.sh shrink-rpath-with-allowed-prefixes.sh \ force-rpath.sh \ + plain-needed.sh \ output-flag.sh build_TESTS = \ diff --git a/tests/plain-needed.sh b/tests/plain-needed.sh new file mode 100755 index 0000000..36267fb --- /dev/null +++ b/tests/plain-needed.sh @@ -0,0 +1,4 @@ +#! /bin/sh +set -e +echo "Confirming main requires libfoo" +../src/patchelf --print-needed main | grep -q libfoo.so |