objdump: Fix private header ('-p') import table output for pe-aarch64

Message ID 20260619134339.73604-1-jon.turney@dronecode.org.uk
State New
Headers
Series objdump: Fix private header ('-p') import table output for pe-aarch64 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Jon Turney June 19, 2026, 1:43 p.m. UTC
  The private header ('-p') import table output for pe-aarch64 (and
probably all other 64-bit arches apart from x86_64) is truncated after the
first import.

The distinction between the conditional branches here should be between
PE32 (32-bit) and PE32+ (somewhat confusingly, the 64-bit version of the
PE format).

PE file format specification [1] states under "Import Lookup Table":

"An import lookup table is an array of 32-bit numbers for PE32 or an
array of 64-bit numbers for PE32+."

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table

2026-06-19  Jon Turney  <jon.turney@dronecode.org.uk>

	* peXXigen.c (pe_print_idata): Fix conditional.
---
 bfd/peXXigen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jan Beulich June 26, 2026, 7:06 a.m. UTC | #1
On 19.06.2026 15:43, Jon Turney wrote:
> The private header ('-p') import table output for pe-aarch64 (and
> probably all other 64-bit arches apart from x86_64) is truncated after the
> first import.
> 
> The distinction between the conditional branches here should be between
> PE32 (32-bit) and PE32+ (somewhat confusingly, the 64-bit version of the
> PE format).
> 
> PE file format specification [1] states under "Import Lookup Table":
> 
> "An import lookup table is an array of 32-bit numbers for PE32 or an
> array of 64-bit numbers for PE32+."
> 
> [1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table
> 
> 2026-06-19  Jon Turney  <jon.turney@dronecode.org.uk>
> 
> 	* peXXigen.c (pe_print_idata): Fix conditional.

Okay, albeit preferably with ...

> --- a/bfd/peXXigen.c
> +++ b/bfd/peXXigen.c
> @@ -1462,7 +1462,7 @@ pe_print_idata (bfd * abfd, void * vfile)
>  	    }
>  
>  	  /* Print HintName vector entries.  */
> -#ifdef COFF_WITH_pex64
> +#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peAArch64 || defined COFF_WITH_peLoongArch64 || defined COFF_WITH_peRiscV64

... this line split for each part to remain within 80 columns (no matter
that other such long lines exist). Perhaps they all should be consolidated
into the checking of a single (new) manifest constant, such that mistakes
like the one being fixed here are easier to avoid. But that's for later.

Jan

Jan
  
Jon Turney June 30, 2026, 7:27 p.m. UTC | #2
On 26/06/2026 08:06, Jan Beulich wrote:
> On 19.06.2026 15:43, Jon Turney wrote:
>> The private header ('-p') import table output for pe-aarch64 (and
>> probably all other 64-bit arches apart from x86_64) is truncated after the
>> first import.
>>
>> The distinction between the conditional branches here should be between
>> PE32 (32-bit) and PE32+ (somewhat confusingly, the 64-bit version of the
>> PE format).
>>
>> PE file format specification [1] states under "Import Lookup Table":
>>
>> "An import lookup table is an array of 32-bit numbers for PE32 or an
>> array of 64-bit numbers for PE32+."
>>
>> [1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table
>>
>> 2026-06-19  Jon Turney  <jon.turney@dronecode.org.uk>
>>
>> 	* peXXigen.c (pe_print_idata): Fix conditional.
> 
> Okay, albeit preferably with ...
> 
>> --- a/bfd/peXXigen.c
>> +++ b/bfd/peXXigen.c
>> @@ -1462,7 +1462,7 @@ pe_print_idata (bfd * abfd, void * vfile)
>>   	    }
>>   
>>   	  /* Print HintName vector entries.  */
>> -#ifdef COFF_WITH_pex64
>> +#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peAArch64 || defined COFF_WITH_peLoongArch64 || defined COFF_WITH_peRiscV64
> 
> ... this line split for each part to remain within 80 columns (no matter

I attach a revised patch since I'm not entirely sure of the desired 
formatting and indentation here.

> that other such long lines exist). Perhaps they all should be consolidated
> into the checking of a single (new) manifest constant, such that mistakes
> like the one being fixed here are easier to avoid. But that's for later.

Yes, that seems like a very good idea.

This condition (or its negation) is repeated multiple times (along with 
some almost similar conditions which would probably benefit from a 
comment if they really are meant to be different).
From 62c10c5d90a3f46f8e26edd2c1d4ff5545e8c55f Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Fri, 19 Jun 2026 13:47:03 +0100
Subject: [PATCH] objdump: Fix private header ('-p') import table output for
 pe-aarch64

The private header ('-p') import table output for pe-aarch64 (and
probably all other 64-bit arches apart from x86_64) is truncated after the
first import.

The distinction between the conditional branches here should be between
PE32 (32-bit) and PE32+ (somewhat confusingly, the 64-bit version of the
PE format).

PE file format specification [1] states under "Import Lookup Table":

"An import lookup table is an array of 32-bit numbers for PE32 or an
array of 64-bit numbers for PE32+."

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table

2026-06-19  Jon Turney  <jon.turney@dronecode.org.uk>

	* peXXigen.c (pe_print_idata): Fix conditional.
---
 bfd/peXXigen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index bdb23dcbcab..f604a84ec0a 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1462,7 +1462,9 @@ pe_print_idata (bfd * abfd, void * vfile)
 	    }
 
 	  /* Print HintName vector entries.  */
-#ifdef COFF_WITH_pex64
+#if defined COFF_WITH_pep || defined COFF_WITH_pex64 \
+    || defined COFF_WITH_peAArch64 || defined COFF_WITH_peLoongArch64 \
+    || defined COFF_WITH_peRiscV64
 	  for (j = 0; idx + j + 8 <= datasize; j += 8)
 	    {
 	      bfd_size_type amt;
  
Jan Beulich July 1, 2026, 6:14 a.m. UTC | #3
On 30.06.2026 21:27, Jon Turney wrote:
> On 26/06/2026 08:06, Jan Beulich wrote:
>> On 19.06.2026 15:43, Jon Turney wrote:
>>> The private header ('-p') import table output for pe-aarch64 (and
>>> probably all other 64-bit arches apart from x86_64) is truncated after the
>>> first import.
>>>
>>> The distinction between the conditional branches here should be between
>>> PE32 (32-bit) and PE32+ (somewhat confusingly, the 64-bit version of the
>>> PE format).
>>>
>>> PE file format specification [1] states under "Import Lookup Table":
>>>
>>> "An import lookup table is an array of 32-bit numbers for PE32 or an
>>> array of 64-bit numbers for PE32+."
>>>
>>> [1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table
>>>
>>> 2026-06-19  Jon Turney  <jon.turney@dronecode.org.uk>
>>>
>>> 	* peXXigen.c (pe_print_idata): Fix conditional.
>>
>> Okay, albeit preferably with ...
>>
>>> --- a/bfd/peXXigen.c
>>> +++ b/bfd/peXXigen.c
>>> @@ -1462,7 +1462,7 @@ pe_print_idata (bfd * abfd, void * vfile)
>>>   	    }
>>>   
>>>   	  /* Print HintName vector entries.  */
>>> -#ifdef COFF_WITH_pex64
>>> +#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peAArch64 || defined COFF_WITH_peLoongArch64 || defined COFF_WITH_peRiscV64
>>
>> ... this line split for each part to remain within 80 columns (no matter
> 
> I attach a revised patch since I'm not entirely sure of the desired 
> formatting and indentation here.

LGTM.

Jan
  

Patch

diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index bdb23dcbcab..c946557f3a0 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1462,7 +1462,7 @@  pe_print_idata (bfd * abfd, void * vfile)
 	    }
 
 	  /* Print HintName vector entries.  */
-#ifdef COFF_WITH_pex64
+#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peAArch64 || defined COFF_WITH_peLoongArch64 || defined COFF_WITH_peRiscV64
 	  for (j = 0; idx + j + 8 <= datasize; j += 8)
 	    {
 	      bfd_size_type amt;