Skip to content

Commit e522b14

Browse files
author
Aaron D. Marasco
committed
Add libasan build option and test print-needed
(cherry picked from commit 288eb61)
1 parent d6b2a72 commit e522b14

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ fi
2424
AC_DEFINE_UNQUOTED(PAGESIZE, ${PAGESIZE})
2525
AC_MSG_RESULT([Setting page size to ${PAGESIZE}])
2626

27+
AC_ARG_WITH([asan],
28+
AS_HELP_STRING([--with-asan], [Link with libasan])
29+
)
30+
AM_CONDITIONAL([WITH_ASAN], [test x"$with_asan" = xyes])
31+
2732
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec])
2833
AC_OUTPUT

src/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
AM_CXXFLAGS = -Wall -std=c++11 -D_FILE_OFFSET_BITS=64
22

3+
if WITH_ASAN
4+
AM_CXXFLAGS += -fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1
5+
endif
6+
37
bin_PROGRAMS = patchelf
48

59
patchelf_SOURCES = patchelf.cc elf.h

src/patchelf.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ I ElfFile<ElfFileParamNames>::rdi(I i)
250250
return r;
251251
}
252252

253-
254253
/* Ugly: used to erase DT_RUNPATH when using --force-rpath. */
255254
#define DT_IGNORE 0x00726e67
256255

@@ -737,7 +736,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
737736
ET_DYN as does LD when linking with pie. If we move PT_PHDR, it
738737
has to stay in the first PT_LOAD segment or any subsequent ones
739738
if they're continuous in memory due to linux kernel constraints
740-
(see BUGS). Since the end of the file would be after bss, we can't
739+
(see BUGS). Since the end of the file would be after bss, we can't
741740
move PHDR there, we therefore choose to leave PT_PHDR where it is but
742741
move enough following sections such that we can add the extra PT_LOAD
743742
section to it. This PT_LOAD segment ensures the sections at the end of

tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ src_TESTS = \
2323
set-interpreter-long.sh set-rpath.sh no-rpath.sh big-dynstr.sh \
2424
set-rpath-library.sh soname.sh shrink-rpath-with-allowed-prefixes.sh \
2525
force-rpath.sh \
26+
plain-needed.sh \
2627
output-flag.sh
2728

2829
build_TESTS = \

tests/plain-needed.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /bin/sh
2+
set -e
3+
echo "Confirming main requires libfoo"
4+
../src/patchelf --print-needed main | grep -q libfoo.so

0 commit comments

Comments
 (0)