From patchwork Thu Apr 16 14:21:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Hawkins X-Patchwork-Id: 133183 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 7F3E74BA2E0A for ; Thu, 16 Apr 2026 14:21:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F3E74BA2E0A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=obs-cr.20251104.gappssmtp.com header.i=@obs-cr.20251104.gappssmtp.com header.a=rsa-sha256 header.s=20251104 header.b=Iq1Zg3we X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id EF2A84BA2E0A for ; Thu, 16 Apr 2026 14:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF2A84BA2E0A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=obs.cr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=obs.cr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF2A84BA2E0A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::331 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776349276; cv=none; b=UbjEsZxZ6xKl9hs9NugldPS3B3nPLHUquX4Mgl8KJzzAt2t6wLJI6yNyTonxmhzwsiunIkkITC4DqFHwdXwyxvWPJwW49kIakB4kpHgCbKYu22m9nUl431Uh1ChloXQ+XxOqXAiqpsqQ7hI9Q6K6Vnf+RUIV1M9kTJmsvQ6Du0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776349276; c=relaxed/simple; bh=mayi0K0gp178PZgfhaQWEwkDFNFkdybUQXUpCXQ2DiA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eK3myX27sew9IeTQ+OW597qOH70OyM/3N7Iq9hwdVVYnOaStRQyq7lLmuPP5uVHZwXgfsXpEIPvSbVLbRR0I82JHycVPkkf47C3Qwye3C5rI69QHFIw7mxY2ZSk17KZY7FiRwpE26gE45wgoiMYLTskp0r704wTGajEd/NsG6Cs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF2A84BA2E0A Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-7d86eb7c854so3974261a34.3 for ; Thu, 16 Apr 2026 07:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obs-cr.20251104.gappssmtp.com; s=20251104; t=1776349275; x=1776954075; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YHgUzVoDnhBCNhbsbvYiAteWiSLAI2cHh8dZGwft46Q=; b=Iq1Zg3weNRE2/RfcESymXR1+H3WHPmWjv17Xee1G6/Lk0Fa0F2E7hyO7n0dLgX0KyE XSASDLJbV5TRNy7EvQk7dPdoGx45qIOzLWOM+0I2Tg+9sGlhXdSSzLW8vUEe/8kRIZVV 3UUzH6koTePfTe265dtobhFYmHrwQc4gjZGYPXjKaboJbFm6IXGrjUFl/+oooDRquN/Q HPGBfpaNqy7BtRNMwtWB2/BpXAgXUw/3DFxGi4EYI1WethhT+14UvgFCd8Yivaj0y1kj jD2s1b1u0DdIGpjXB8r3fETq8q11Ic5sHTXYaCwBV7TUiSYdfmIufGEl/GVWhw4pH9yd JMjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776349275; x=1776954075; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state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+T0J88LFEUfQa4NhDlO2CeQytseXUon OoH9GZamrewl5ctQa5abBCH4MGZhgfrVAH9GFkKlvUOKoMvRFmHNk5OKfAQu0PdE3sbqS3t5166 JxU= X-Received: by 2002:a05:6820:2089:b0:684:7d3b:4378 with SMTP id 006d021491bc7-68be5b5a464mr12676136eaf.4.1776349273307; Thu, 16 Apr 2026 07:21:13 -0700 (PDT) Received: from ininer.rhod.uc.edu ([129.137.96.15]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6932dfb8a2esm2585697eaf.11.2026.04.16.07.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 07:21:12 -0700 (PDT) From: Will Hawkins To: binutils@sourceware.org Cc: Will Hawkins Subject: [PATCH] binutils/dwarf: Print embedded source, when available Date: Thu, 16 Apr 2026 10:21:06 -0400 Message-ID: <20260416142108.2422501-1-hawkinsw@obs.cr> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org When an object file with debugging information has the source embedded (via DW_LNCT_LLVM_source), the `--dwarf=rawline` output from objdump prints the source but the format leaves something to be desired. This small patch makes it so that the source is printed started on a new line in the File Name Table when the user invokes `objdump` with `--dwarf=rawline`. The DW_LNCT_LLVM_source line number header entry format is slated to be added to DWARFv6: https://dwarfstd.org/issues/180201.1.html and lldb supports it (and gdb will soon support it). If this is a feature that seems worthwhile, I would be more than happy to add tests. I just didn't want to waste anyone's time with a long(ish) patch at first. I tried to follow all the proper coding style requirements, but I am sure that there is something that I missed! Sorry in advance! --- binutils/dwarf.c | 32 ++++++++++++++++++++++++++------ include/dwarf2.h | 1 + 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index fa8dce25..fbf42c29 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -5776,7 +5776,7 @@ display_formatted_table (unsigned char *data, { unsigned char *format_start, format_count, *format, formati; uint64_t data_count, datai; - unsigned int namepass, last_entry = 0; + unsigned int namepass, namesourcepass, last_entry = 0; const char * table_name = is_dir ? N_("Directory Table") : N_("File Name Table"); SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); @@ -5847,6 +5847,9 @@ display_formatted_table (unsigned char *data, case DW_LNCT_MD5: printf (_("\tMD5\t\t\t")); break; + case DW_LNCT_LLVM_source: + // Skip source ... display on next line. + break; default: printf (_("\t(Unknown format content type %" PRIu64 ")"), content_type); @@ -5861,8 +5864,9 @@ display_formatted_table (unsigned char *data, unsigned char *datapass = data; printf (" %d", last_entry++); - /* Delay displaying name as the last entry for better screen layout. */ - for (namepass = 0; namepass < 2; namepass++) + /* Delay displaying name/source as the last entry for better screen + layout. */ + for (namesourcepass = 0; namesourcepass < 3; namesourcepass++) { format = format_start; data = datapass; @@ -5872,13 +5876,29 @@ display_formatted_table (unsigned char *data, READ_ULEB (content_type, format, end); READ_ULEB (form, format, end); - bool do_loc = (content_type == DW_LNCT_path) != (namepass == 1); + + bool do_loc = (content_type == DW_LNCT_path) + != (namesourcepass == 1); + do_loc |= (content_type == DW_LNCT_LLVM_source) + != (namesourcepass == 2); + + char delimiter = '\t'; + + /* Print Source last (if available) and print it + starting on the next line. */ + if (namesourcepass == 2 && content_type == DW_LNCT_LLVM_source) + { + delimiter = ' '; + putchar ('\n'); + printf (" Source:"); + } data = read_and_display_attr_value (0, form, 0, start, data, end, 0, linfo->li_address_size, linfo->li_offset_size, linfo->li_version, NULL, - do_loc, section, NULL, '\t', - -1, false, 0, 0, false); + do_loc, section, NULL, + delimiter, -1, false, 0, 0, + false); } } diff --git a/include/dwarf2.h b/include/dwarf2.h index bf9287f1..ee546a40 100644 --- a/include/dwarf2.h +++ b/include/dwarf2.h @@ -294,6 +294,7 @@ enum dwarf_line_number_content_type DW_LNCT_size = 0x4, DW_LNCT_MD5 = 0x5, DW_LNCT_lo_user = 0x2000, + DW_LNCT_LLVM_source = 0x2001, DW_LNCT_hi_user = 0x3fff };