HomePhabricator

[ubsan] Function Sanitizer: Don't require writable text segments

Description

[ubsan] Function Sanitizer: Don't require writable text segments

This change will make it possible to use -fsanitize=function on Darwin and
possibly on other platforms. It fixes an issue with the way RTTI is stored into
function prologue data.

On Darwin, addresses stored in prologue data can't require run-time fixups and
must be PC-relative. Run-time fixups are undesirable because they necessitate
writable text segments, which can lead to security issues. And absolute
addresses are undesirable because they break PIE mode.

The fix is to create a private global which points to the RTTI, and then to
encode a PC-relative reference to the global into prologue data.

Differential Revision: https://reviews.llvm.org/D37597

Details

Committed
vedantkSep 12 2017, 5:04 PM
Differential Revision
D37597: [ubsan] Function Sanitizer: Don't require writable text segments
Parents
rL313095: Add a comment about a workaround for ld.gold -r.
Branches
Unknown
Tags
Unknown