Created attachment 9538 [details]
.cfi_sections had consistency checking added as part of support for new compact eh_frame sections. The original check was simply to disallow any variation in the sections specified when multiple .cfi_sections directives were seen. This caused some issues as the directive is supposed to allow additional sections to be listed via multiple instances.
As it happens the original compact eh support did not actually prevent switching to the compact form if the first .cfi_sections came after the first CFI data:
The fix for PR gas/19614 fixed both the issues above but ended up still left the consistency check more aggressive that it needs to be.
For background... the need for the consistency check comes from the change in behavior of all the other .cfi* directives depending on whether the original or compact form of eh_frame is to be generated.
Other non-GCC users of gas however now face a change in behavior that is not technically necessary. I.e. llvm as per https://llvm.org/bugs/show_bug.cgi?id=29017.
A reasonable fix would be to make the consistency check specifically about the one problem case where one turns on compact EH after emitting CFI data. This could be done by looking at the compact_eh global changing from false to true (when cfi_sections_set is true) but that would allow the following which may be misleading:
I.e. the use of .eh_frame may mean a user expects the non-compact form.
Instead we can check if a new .cfi_sections specifies either of .eh_frame or .eh_frame_entry and if so verifies whether this is now different from what was there before. Specifically it means the testcase directly above is rejected and the one below is accepted:
The master branch has been updated by Matthew Fortune <email@example.com>:
Author: Matthew Fortune <firstname.lastname@example.org>
Date: Thu Sep 29 11:13:46 2016 +0100
Refine .cfi_sections check to only consider compact eh_frame
The .cfi_sections directive can be safely used multiple times
with different sections named at any time unless the compact form
of exception handling is requested after CFI information has
been emitted. Only the compact form of CFI information changes
the way in which CFI is generated and therefore cannot be
retrospectively requested after generating CFI information.
* dw2gencfi.c (dot_cfi_sections): Refine the check for
inconsistent .cfi_sections to only consider compact vs non
* testsuite/gas/cfi/cfi-common-9.d: New file.
* testsuite/gas/cfi/cfi-common-9.s: New file.
* testsuite/gas/cfi/cfi.exp: Run new test.
Fixed on master