This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Forbid section anchors for ASan build (PR sanitizer/81697)

On 08/08/2017 12:46 AM, Vyacheslav Barinov wrote:
> Hello,
> Andrew Pinski <> writes:
>> On Mon, Aug 7, 2017 at 11:15 PM, Slava Barinov <> wrote:
>>>        gcc/
>>>        * varasm.c (use_object_blocks_p): Forbid section anchors for ASan
>>>        gcc/testsuite/
>>>        * g++.dg/asan/ New test to test global
>>>        variables alignment.
>> Can you describe this a little bit more?  What is going wrong here?
>> Is it because there is no red zone between the variables?
> I've described situation in bugzilla PR 81697 with compiled files dumps, but
> briefly yes, red zone size is incorrect between global variables.
> On certain platforms (we checked at least arm and ppc) the flow is following:
> make_decl_rtl() calls create_block_symbol() on decl tree with ASan global
> variable describing a string. But then get_variable_section() returns wrong
> section (.rodata.str1.4 in my case) because check in asan_protect_global()
> returns false due to !DECL_RTL_SET_P check.
> When variable is placed not into .rodata, but into .rodata.str ld treats it as
> string and just shrinks the large part of red zone silently (gold at least
> prints warning about wrong string alignment). But in run time libasan expects
> that red zone is still there and reports false positives.
> In order to prevent the setting of RTL before ASan handling I tried to
> reproduce the x86_64 behavior and found that use_object_blocks_p() returns
> false for that platform. Accordingly to the function comment it reports if
> 'current compilation mode benefits from grouping', and just switching it off
> for any ASan builds resolves the issue.
>> Also I noticed you are using .cc as the testcase file name, why don't
>> you use .C instead and then you won't need the other patch which you
>> just posted.
> Okay, attaching rebased version.
In many ways it'd be better if asan could be made to work with section
anchors.  Doing so means the code we're running for asan more closely
matches what we're running in the normal case.

But I'll defer to Jakub and Marek as they know the sanitizers far better
than I do and are more familiar with the expected tradeoffs.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]