Re: [PATCH v3] gdb, configure: Add disable-formats option for configure

Guinevere Larsen
2025-03-07T12:50:05Z

On 3/7/25 9:09 AM, Eli Zaretskii wrote:
>> From: Guinevere Larsen <guinevere@redhat.com>
>> Cc: Guinevere Larsen <guinevere@redhat.com>
>> Date: Fri, 7 Mar 2025 08:58:21 -0300
>>
>> GDB has support for many binary file formats, some which might be very
>> unlikely to be found in some situations (such as the COFF format in
>> linux). This commit introduces the option for a user to choose which
>> formats GDB will support at build configuration time.
>>
>> This is especially useful to avoid possible security concerns with
>> readers that aren't expected to be used at all, as they are one of
>> the simplest vectors for an attacker to try and hit GDB with. This
>> change can also reduce the size of the final binary, if that is a
>> concern.
>>
>> This commit adds a switch to the configure script allowing a user to
>> only enable selected file formats, called --enable-binary-file-formats.
>> The default behavior when the switch is omitted is to compile all file
>> formats, keeping the original behavior of the script. At the time of
>> this commit, the valid options for this option are: dbx, coff (which
>> includes coff-pe), xcoff, mips, elf, macho and all. All is treated
>> especially, activating all supported readers.
>>
>> A few targets may require specific binary file format support, as they
>> directly call functions defined by the file reader. Specifically,
>> windows targets require coff support, and rs6000 aix and lynx178 targets
>> require xcoff support. Considering that those formats are the main - or
>> only - one available in those targets, I believe it makes sense to
>> re-enable those readers. If that happens, the script will emit the
>> following warning:
>>
>> FOO is required to support one or more requested targets. Adding it
>>
>> Users aren't able to force the disabling of those formats, since GDB
>> will not compile without those readers. Ideally we'd like to be able
>> to disable even those formats, in case a user wants to build GDB only
>> to examine remote files for example, but the current infrastructure
>> for the file format readers doesn't allow us to do it.
>>
>> Mach-O and elf support are also dependent on BFD support being compiled
>> in. In case one of those was requested and BFD does not support them,
>> the following error is emitted:
>>
>> FOO was requested, but BFD does not support it.
>>
>> Finally, this configure switch is also printed by the "show
>> configuration" command in GDB.
>> ---
>> gdb/Makefile.in | 13 +++----
>> gdb/NEWS | 11 ++++++
>> gdb/README | 24 +++++++++++++
>> gdb/config.in | 3 ++
>> gdb/configure | 81 +++++++++++++++++++++++++++++++++++++++++---
>> gdb/configure.ac | 65 +++++++++++++++++++++++++++++++++--
>> gdb/configure.format | 51 ++++++++++++++++++++++++++++
>> gdb/configure.tgt | 20 +++++++++--
>> gdb/doc/gdb.texinfo | 8 +++++
>> gdb/top.c | 5 +++
>> 10 files changed, 264 insertions(+), 17 deletions(-)
>> create mode 100644 gdb/configure.format
> Thanks, but can you describe the changes sine v2, so I could determine
> whether I need to review the documentation parts of this? TIA.
>
oh sorry, I knew I had forgotten something.

The change is pretty trivial, I just updated the documentation to have
the correct  flag. I believe there should be nothing for you to review I
just forgot to add your tag.

--
Cheers,
Guinevere Larsen
She/Her/Hers