[Dwarf-Discuss] Interpretation of DWARF FDE->CIE_pointer field for .debug_frame

Jakub Jelinek jakub at redhat.com
Mon Jun 24 00:03:35 PDT 2013


On Mon, Jun 24, 2013 at 12:06:27PM +0530, Vineet Gupta wrote:
> I had a question about interpretation of FDE's CIE_pointer field (for .debug_frame)
> 
> The spec say (from dwarf4 version although it really doesn't matter):
> 
> "2. CIE_pointer (4 or 8 bytes, see Section 7.4)
> A constant offset into the .debug_frame section that denotes the CIE that is
> associated with this FDE."
> 
> Does "offset" above mean offset from current location (in FDE) to CIE or does it
> mean offset from start of .debug_frame to the CIE. Per Ian Lance Taylor's blog,
> and if I'm interpreting it correctly, (http://www.airs.com/blog/archives/460) it
> seems to be latter.

CIE_pointer in .debug_frame is relative to the start of the .debug_frame
section.  In .eh_frame section it is encoded based on the selected encoding,
often relative to the start of the CIE_pointer.

> ...
> .LSFDE0:
>     .4byte    @.LEFDE0- at .LASFDE0   --> FDE
> .LASFDE0:
>     .4byte    @.Lframe0            --> CIE pointer - direct reference to CI (not
> offset from start of .debug_frame)

This looks fine.

> ....
> 
> This direct reference to start of CIE is causing objdump to reference invalid CIE
> and hence print invalid CFI - although the CFI itself is valid since the
> code_factor and such are seeded from a bogus CIE.
> 
> 00000060 00000014 80e0c000 FDE cie=48b25ff8   pc=80a680d4..80a6810a
> ...                                                              ^^^^^^

The 48b25ff8 looks wrong though, it would really surprise me if .debug_frame
section was more than 1GB big.  So perhaps your assembler or linker don't
handle it properly?

> Looking at gcc 4.8 source : gcc/dwarf2out.c : It seems to hint that the
> CIE_pointer needs to be relative to .debug_frame (just as I think)
> 
> +  if (for_eh)
> +    dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
> +  else
> +    dw2_asm_output_offset (DWARF_OFFSET_SIZE, section_start_label,
>  +              debug_frame_section, "FDE CIE offset");
> 
> However to not generate a direct reference, most targets need to implement
> ASM_OUTPUT_DWARF_OFFSET which is not really the case.

ASM_OUTPUT_DWARF_OFFSET is there just for targets where the normal way
doesn't produce desired result.

	Jakub



More information about the Dwarf-Discuss mailing list