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

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 15:30:06 PDT 2017


vsk created this revision.

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. For now, the
behavior change is only enabled for Darwin.


https://reviews.llvm.org/D37597

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/catch-undef-behavior.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37597.114267.patch
Type: text/x-patch
Size: 8569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170907/8ed8a49f/attachment.bin>


More information about the cfe-commits mailing list