[PATCH 1/5] readelf: fold get_{32,64}bit_program_headers()
Jan Beulich
jbeulich@suse.com
Mon Jul 27 11:24:39 GMT 2026
On 27.07.2026 13:20, H.J. Lu wrote:
> On Mon, Jul 27, 2026 at 5:20 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> PR binutils/34356
>>
>> They're identical except for the types used and the order of fields
>> processed. The latter doesn't matter for correctness, and the former can
>> be addressed by compiling the same code twice.
>>
>> --- a/binutils/readelf.c
>> +++ b/binutils/readelf.c
>> @@ -40,6 +40,8 @@
>> ELF file than is provided by objdump. In particular it can display DWARF
>> debugging information which (at the moment) objdump cannot. */
>>
>> +#ifndef ElfXX
>> +
>> #include "sysdep.h"
>> #include <assert.h>
>> #include <time.h>
>> @@ -7366,14 +7368,21 @@ process_file_header (Filedata * filedata
>> return true;
>> }
>>
>> +#define ElfXX(n) Elf32 ## n
>> +#include "readelf.c"
>> +#define ElfXX(n) Elf64 ## n
>> +#include "readelf.c"
>
> Can we extract this piece code into readelf.h and include
> readelf.h instead?
I'm sure we (technically) could, but I'm unconvinced we should. Personally
I don't consider such a valid use of "header files". I did consider adding
a new .c file, but I couldn't think of a name which I would be at least
reasonably okay with.
Jan
More information about the Binutils
mailing list