[PATCH] GDB: Fix detection of ELF support when configuring with -Werror

Simon Marchi simark@simark.ca
Thu Nov 12 14:25:28 GMT 2020


On 2020-11-12 4:25 a.m., Alexander Richardson wrote:
> On Wed, 11 Nov 2020 at 20:48, Simon Marchi <simark@simark.ca> wrote:
>>
>> On 2020-11-11 4:20 a.m., Alex Richardson via Gdb-patches wrote:
>>> I was getting "I'm sorry, Dave, I can't do that.  Symbol format `elf64-littleriscv' unknown."
>>> errors after updating from GDB 8.3 to 10. Bisecting showed that since
>>> commit 1ff6de031241c59d0ff9fa01d3c0a4049b0e97c9, bfd.h depends on strncmp()
>>> being present, so configuring with -Werror results in the check for ELF
>>> support in BFD failing:
>>> .../gdb/gdb/../bfd/elf-bfd.h: In function 'bfd_section_is_ctf':
>>> .../gdb/gdb/../bfd/elf-bfd.h:3086:10: error: implicit declaration of function 'strncmp' [-Werror=implicit-function-declaration]
>>>    return strncmp (name, ".ctf", 4) == 0 && (name[4] == 0 || name[4] == '.');
>>> ---
>>>  gdb/acinclude.m4 | 1 +
>>>  gdb/configure    | 2 ++
>>>  2 files changed, 3 insertions(+)
>>>
>>> diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
>>> index 64574e26314..68520d6d938 100644
>>> --- a/gdb/acinclude.m4
>>> +++ b/gdb/acinclude.m4
>>> @@ -266,6 +266,7 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
>>>      [AC_LINK_IFELSE(
>>>         [AC_LANG_PROGRAM(
>>>         [#include <stdlib.h>
>>> +        #include <string.h>
>>>          #include "bfd.h"
>>>          #include "$4"],
>>>         [return $3;]
>>> diff --git a/gdb/configure b/gdb/configure
>>> index 4a03cd9c3ec..ddbeefe426e 100755
>>> --- a/gdb/configure
>>> +++ b/gdb/configure
>>> @@ -16745,6 +16745,7 @@ else
>>>    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
>>>  /* end confdefs.h.  */
>>>  #include <stdlib.h>
>>> +        #include <string.h>
>>>          #include "bfd.h"
>>>          #include "elf-bfd.h"
>>>  int
>>> @@ -16858,6 +16859,7 @@ else
>>>    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
>>>  /* end confdefs.h.  */
>>>  #include <stdlib.h>
>>> +        #include <string.h>
>>>          #include "bfd.h"
>>>          #include "mach-o.h"
>>>  int
>>> --
>>> 2.29.1
>>>
>>
>> Since elf-bfd.h uses strncmp, I think it should include string.h.  Is there a good reason not to do that?
>>
>
> Hi Simon,
>
> that's what I originally planned, but it seems like elf-bfd.h (and the
> headers it includes) don't include any system headers. Since I'm not
> familiar with any of this code I assumed this was intentional.
>
> Alex
>

Hi binutils@,

Could you check the discussion above?  Is there a reason elf-bfd.h
doesn't include the header file it needs to use the functions it uses?

Simon


More information about the Binutils mailing list