* [debug] Don't add DW_AT_low_pc if the CU has no associated code
@ 2011-03-31 21:25 Mark Wielaard
2011-04-01 15:38 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2011-03-31 21:25 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
Hi,
The dwarf spec (v4 - 2.17) explicitly says that CUs (and other DIEs)
which have no associated machine code should not have a DW_AT_low_pc,
DW_AT_high_pc or DW_AT_ranges set. This patch also makes gcc not output
DW_AT_entry_pc for a CU. Which also wasn't according to spec and gcc
has been outputting DW_AT_low_pc for years already. The condition being
dwarf_version >= 4, assuming any consumers updated to Dwarf 4 will have
been following the spec. I checked gdb and elfutils already check for
DW_AT_low_pc.
2011-03-31 Mark Wielaard <mjw@redhat.com>
* dwarf2out.c (dwarf2out_finish): Don't add low_pc and/or
high_pc attribute if the CU has no associated code. Only output
DW_AT_entry_pc for CU if not generating strict dwarf and
dwarf_version < 4.
OK to commit?
Bootstrapped and no regressions on GNU/Linux x86_64.
Cheers,
Mark
[-- Attachment #2: cu-no-code.patch --]
[-- Type: text/x-patch, Size: 2033 bytes --]
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 91be9a4..6b9561c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23647,23 +23647,18 @@ dwarf2out_finish (const char *filename)
if (!have_multiple_function_sections
|| (dwarf_version < 3 && dwarf_strict))
{
- add_AT_lbl_id (comp_unit_die (), DW_AT_low_pc, text_section_label);
- add_AT_lbl_id (comp_unit_die (), DW_AT_high_pc, text_end_label);
+ /* Don't add if the CU has no associated code. */
+ if (text_section_used)
+ {
+ add_AT_lbl_id (comp_unit_die (), DW_AT_low_pc, text_section_label);
+ add_AT_lbl_id (comp_unit_die (), DW_AT_high_pc, text_end_label);
+ }
}
-
else
{
unsigned fde_idx = 0;
bool range_list_added = false;
- /* We need to give .debug_loc and .debug_ranges an appropriate
- "base address". Use zero so that these addresses become
- absolute. Historically, we've emitted the unexpected
- DW_AT_entry_pc instead of DW_AT_low_pc for this purpose.
- Emit both to give time for other tools to adapt. */
- add_AT_addr (comp_unit_die (), DW_AT_low_pc, const0_rtx);
- add_AT_addr (comp_unit_die (), DW_AT_entry_pc, const0_rtx);
-
if (text_section_used)
add_ranges_by_labels (comp_unit_die (), text_section_label,
text_end_label, &range_list_added);
@@ -23684,7 +23679,18 @@ dwarf2out_finish (const char *filename)
}
if (range_list_added)
- add_ranges (NULL);
+ {
+ /* We need to give .debug_loc and .debug_ranges an appropriate
+ "base address". Use zero so that these addresses become
+ absolute. Historically, we've emitted the unexpected
+ DW_AT_entry_pc instead of DW_AT_low_pc for this purpose.
+ Emit both to give time for other tools to adapt. */
+ add_AT_addr (comp_unit_die (), DW_AT_low_pc, const0_rtx);
+ if (! dwarf_strict && dwarf_version < 4)
+ add_AT_addr (comp_unit_die (), DW_AT_entry_pc, const0_rtx);
+
+ add_ranges (NULL);
+ }
}
if (debug_info_level >= DINFO_LEVEL_NORMAL)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [debug] Don't add DW_AT_low_pc if the CU has no associated code
2011-03-31 21:25 [debug] Don't add DW_AT_low_pc if the CU has no associated code Mark Wielaard
@ 2011-04-01 15:38 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2011-04-01 15:38 UTC (permalink / raw)
To: Mark Wielaard; +Cc: gcc-patches
On 03/31/2011 02:17 PM, Mark Wielaard wrote:
> * dwarf2out.c (dwarf2out_finish): Don't add low_pc and/or
> high_pc attribute if the CU has no associated code. Only output
> DW_AT_entry_pc for CU if not generating strict dwarf and
> dwarf_version < 4.
Ok.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-01 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-31 21:25 [debug] Don't add DW_AT_low_pc if the CU has no associated code Mark Wielaard
2011-04-01 15:38 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).