Skip to content

Commit

Permalink
rrpage: use Linux vDSO soname
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
Bob131 authored and rocallahan committed Aug 11, 2021
1 parent 056e602 commit 4857fd6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ foreach(file ${RR_PAGE_FILES})
set_source_files_properties("${CMAKE_SOURCE_DIR}/src/preload/${file}"
PROPERTIES COMPILE_FLAGS ${PRELOAD_COMPILE_FLAGS})
endforeach(file)
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}")

# Since librrpage replaces the kernel vDSO for processes exec'd by rr,
# we want it to have the same SONAME as the real vDSO to trick things
# like AddressSanitizer into recognising it as the vDSO.
set_target_properties(rrpage PROPERTIES NO_SONAME ON)
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}")
set_target_properties(rrpage PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld)
# CMake seems to have trouble generating the link line without this
set_target_properties(rrpage PROPERTIES LINKER_LANGUAGE C)
Expand Down Expand Up @@ -672,7 +677,8 @@ if(rr_32BIT AND rr_64BIT)
PROPERTIES COMPILE_FLAGS "-m32 ${PRELOAD_COMPILE_FLAGS}")
endforeach(file)

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}")
set_target_properties(rrpage_32 PROPERTIES NO_SONAME ON)
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}")
set_target_properties(rrpage_32 PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld)
set_target_properties(rrpage_32 PROPERTIES LINKER_LANGUAGE C)

Expand Down

0 comments on commit 4857fd6

Please sign in to comment.