Skip to content

Commit 5a7d3dd

Browse files
committed
rrpage: use Linux vDSO soname
AddressSanitizer complains if it isn't the first shared object in the link map besides the vDSO. It checks for the vDSO by testing whether the DT_SONAME of the object starts with 'linux-'. With the introduction of librrpage, this check no longer passes and causes ASan-instrumented programs to abort when being recorded by rr. This patch alters the linker arguments used for producing the librrpage dummy vDSO such that its SONAME is 'linux-vdso.so.1'.
1 parent 2479604 commit 5a7d3dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,12 @@ foreach(file ${RR_PAGE_FILES})
342342
set_source_files_properties("${CMAKE_SOURCE_DIR}/src/preload/${file}"
343343
PROPERTIES COMPILE_FLAGS ${PRELOAD_COMPILE_FLAGS})
344344
endforeach(file)
345-
set_target_properties(rrpage PROPERTIES LINK_FLAGS "-Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -nostartfiles -nostdlib -Wl,-z,max-page-size=0x1000 ${LINKER_FLAGS}")
345+
346+
# Since librrpage replaces the kernel vDSO for processes exec'd by rr,
347+
# we want it to have the same SONAME as the real vDSO to trick things
348+
# like AddressSanitizer into recognising it as the vDSO.
349+
set_target_properties(rrpage PROPERTIES NO_SONAME ON)
350+
set_target_properties(rrpage PROPERTIES LINK_FLAGS "-Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -nostartfiles -nostdlib -Wl,-z,max-page-size=0x1000 -Wl,-soname,linux-vdso.so.1 ${LINKER_FLAGS}")
346351
set_target_properties(rrpage PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld)
347352
# CMake seems to have trouble generating the link line without this
348353
set_target_properties(rrpage PROPERTIES LINKER_LANGUAGE C)
@@ -664,7 +669,8 @@ if(rr_32BIT AND rr_64BIT)
664669
PROPERTIES COMPILE_FLAGS "-m32 ${PRELOAD_COMPILE_FLAGS}")
665670
endforeach(file)
666671

667-
set_target_properties(rrpage_32 PROPERTIES LINK_FLAGS "-m32 -Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -nostartfiles -nostdlib ${LINKER_FLAGS}")
672+
set_target_properties(rrpage_32 PROPERTIES NO_SONAME ON)
673+
set_target_properties(rrpage_32 PROPERTIES LINK_FLAGS "-m32 -Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -nostartfiles -nostdlib -Wl,-soname,linux-vdso.so.1 ${LINKER_FLAGS}")
668674
set_target_properties(rrpage_32 PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld)
669675
set_target_properties(rrpage_32 PROPERTIES LINKER_LANGUAGE C)
670676

0 commit comments

Comments
 (0)