Skip to content

Commit e6d11d9

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 0289253 commit e6d11d9

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 -Wl,--hash-style=both -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 -Wl,--hash-style=both -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)
@@ -672,7 +677,8 @@ if(rr_32BIT AND rr_64BIT)
672677
PROPERTIES COMPILE_FLAGS "-m32 ${PRELOAD_COMPILE_FLAGS}")
673678
endforeach(file)
674679

675-
set_target_properties(rrpage_32 PROPERTIES LINK_FLAGS "-m32 -Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -Wl,--hash-style=both -nostartfiles -nostdlib ${LINKER_FLAGS}")
680+
set_target_properties(rrpage_32 PROPERTIES NO_SONAME ON)
681+
set_target_properties(rrpage_32 PROPERTIES LINK_FLAGS "-m32 -Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -Wl,--hash-style=both -nostartfiles -nostdlib -Wl,-soname,linux-vdso.so.1 ${LINKER_FLAGS}")
676682
set_target_properties(rrpage_32 PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld)
677683
set_target_properties(rrpage_32 PROPERTIES LINKER_LANGUAGE C)
678684

0 commit comments

Comments
 (0)