[Bug c++/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 Nistor, Mihail-Marian changed: What|Removed |Added Severity|critical|blocker
[Bug c++/60387] New: The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 Bug ID: 60387 Summary: The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards. Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m_nistor at yahoo dot com The gcc compiler for the ppc architecture doesn't use DWARF Register Number Mapping that is defined in the PPC ABI standards. Just an example for the first vector register (vr0): the ppc gcc generates 100 instead of 1124. The gcc compiler doesn't emit .debug_frame section and it prefers to emit only the .eh_fram e section. The .eh_frame section is used by application to handle the exception. This section is part of the C++ ABI. The .eh_frame section is not a debug section and this section should not be used by debugger for unwinding stack frame, this statement was also done by Michael Eager who is Chair of DWARF Standards Committee Members. You can see below more information about this: http://wiki.dwarfstd.org/index.php?title=Exception_Handling Relationship with DWARF Although the C++ ABI data in the .eh_frame section uses the data format described by the DWARF Standard (with some extensions), this section (and other sections used by exception handling, such as .eh_frame_hdr and .gcc_except_table) are not defined by the DWARF Standard. The DWARF Standard does not describe the extensions to support exception handling nor the routines which must be called by a program to use this data. The DWARF Debugging Format Committee does not specify the contents of these sections or the functionality which must be provided by the language run time system to support exception handling. The .eh_frame section is not used for debugging. Whether it is generated or not is independent of whether DWARF debug data is generated. All DWARF data is contained in sections with names starting with .debug, which may be removed from a program without affecting the program's normal execution. It is common practice to "strip" debugging sections from a program before putting it into production, either to reduce the program size, make reverse engineering more difficult, or both. Removing the .eh_frame section (whether the DWARF .debug sections are left in place or not) has a high likelihood of adversely affecting a program's behaviour, especially when it encounters an unexpected condition. Unfortunately, it has been a common shorthand to refer to the C++ ABI exception handling methodology using .eh_frame with "DWARF exception handling," or similar phrases. Perhaps this because it is easier to say this than the unwieldy "C++ exception handling using the DWARF Call Frame Information format with extensions", or the misleading "C++ ABI for IA-64" or "SVR4 ABI AMD64 Processor Supplement", especially when discussing a processor other than Itanium or AMD-64. This leads to occasional confusion, where people may look at the DWARF Specification for a description of the C++ ABI exception handling method, or where vulnerabilities in the EH scheme are incorrectly characterized as DWARF vulnerabilities, as in the otherwise excellent paper mentioned below.
[Bug c++/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 --- Comment #2 from Nistor, Mihail-Marian --- More details about how to reproduce the first problem. By using the gcc version - GNU C 4.8.1 20130531 (Wed Sep 4 08:04:01 CDT 2013) I have defined a local variable (vf1) that has a vector resister as storage class, the C definition is below: register vector float vf1 = {0.1f, 0.2f, 0.3f, 0.4f}; A piece of dump from .debug_info is below: <2><24f>: Abbrev Number: 7 (DW_TAG_variable) <250> DW_AT_name: vf1 <254> DW_AT_decl_file : 1 <255> DW_AT_decl_line : 13 <256> DW_AT_type: <0x2ee> <25a> DW_AT_location: 2 byte block: 90 64 (DW_OP_regx: 100 (r100)) // the correct expression should be: (DW_OP_regx: 1124 (r1124)) A piece of dump from .debug_frame is below: 00d0 0034 00c0 FDE cie=00c0 pc=0010018c..001002fc DW_CFA_advance_loc: 4 to 00100190 DW_CFA_def_cfa_offset: 192 DW_CFA_advance_loc: 84 to 001001e4 DW_CFA_offset_extended_sf: r65 at cfa+4 DW_CFA_offset: r31 at cfa-4 DW_CFA_offset_extended: r100 at cfa-160 // the correct expression should be: r1124 at cfa-160 As you can see, the compiler uses a wrong DWARF register index for vector register, in this case the compiler should generate 1124 (r1124) instead of 100 (r100), so the ppc gcc compiler is not compatible with the PPC ABI. Please let me know if you need more information to reproduce the second problem.
[Bug target/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 --- Comment #4 from Nistor, Mihail-Marian --- Created attachment 32281 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32281&action=edit I have attached all information you requested. I have attached all information you requested. As you can see, in the main.o.txt file the section .debug_frame was not generated for the C++ application.
[Bug target/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 --- Comment #7 from Nistor, Mihail-Marian --- Hello, Doe to the fact that the gcc is not compatible with the DWARF and PPC ABI for the PPC processors, as you said that is a fact of life and we need to live with it. Users must always be informed when a compiler does not comply with an ABI, so please add a notice in the release note to inform the user that the ppc gcc is not compatible with the DWARF and PPC ABI. And please also add information about exception from these standards and provide information about the new DWARF register number mapping that is used by gcc in the .eh_frame section. My 2 cents. Mihai
[Bug target/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 Nistor, Mihail-Marian changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID |--- --- Comment #8 from Nistor, Mihail-Marian --- Hello, Doe to the fact that the gcc is not compatible with the DWARF and PPC ABI for the PPC processors, as you said that is a fact of life and we need to live with it. Users must always be informed when a compiler does not comply with an ABI, so please add a notice in the release note to inform the user that the ppc gcc is not compatible with the DWARF and PPC ABI. And please also add information about exception from these standards and provide information about the new DWARF register number mapping that is used by gcc in the .eh_frame section. My 2 cents. Mihai
[Bug target/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 --- Comment #10 from Nistor, Mihail-Marian --- Could you please show me where this information is in the GNU ABI? My request is to add all exceptions from the standards to release note.
[Bug target/60387] The gcc compiler for the ppc architecture is not compatible with PPC ABI and DWARF standards.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60387 --- Comment #12 from Nistor, Mihail-Marian --- The ppc gcc uses the DWARF register number mapping that is defined by the psABI, but the main problem is: the psABI is for AI32/64 architectures. The DWARF register number mapping is also used to encode all debug data information so the affected DWARF sections are: .debug_info and .debug_frame. The ppc gcc must document division from the PPC ABI standard (see an example at comment 2). It should also specify that the internal/unofficial DWARF register number mapping will be used for .eh_frame and DWARF standard. The AI32/64 ABI consists of the following: psABI, ABI-EH and SWCONV (see more information at http://mentorembedded.github.io/cxx-abi/abi.html on 1.5 Base Document). An important notice here is the primary API for this architecture (psABI) refers ABI-EH and SWCONV documents. In the SWCONV document the AI32/64 describes how the debugger should access the data that are particular for this architecture (see more information in 11. Stack Unwinding and Exception Handling chapter). I didn’t see any documents on how the support is done for PPC architecture. This document must be provided and the PPC ABI must refer to it. I don’t think that the most important rules from the “11.3 Coding Conventions for Reliable Unwinding” chapter from SWCONV were followed by the ppc gcc implementation. The “prolog” and “epilog” ranges do not obey these rules defined in 11 chapter. Until the above problems is solved we have a reference from DWARF3/4 that should be resolved by using undocumented ABI (the test case is: the debugger should compute the location for a local variable that is related to the frame base (DW_AT_location is defined as DW_OP_fbreg) and the value for DW_AT_frame_base is defined as DW_OP_call_frame_cfa for current function). I have been looking to see a full specification and implementation for this custom solution.