Avoid -Waddress warnings in readelf
authorAlan Modra <amodra@gmail.com>
Thu, 21 Oct 2021 06:32:06 +0000 (17:02 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 21 Oct 2021 11:39:21 +0000 (22:09 +1030)
commit84714f86b37ae36fedca2c0936c7d274a4000900
tree443b0edc5e874b7b6220256863458f97f4ee5ecf
parentf4efb229b72a133c6a5472ebbf484f5207dc0e56
Avoid -Waddress warnings in readelf

Mainline gcc:
readelf.c: In function 'find_section':
readelf.c:349:8: error: the comparison will always evaluate as 'true' for the pointer operand in 'filedata->section_headers + (sizetype)((long unsigned int)i * 80)' must not be NULL [-Werror=address]
  349 |   ((X) != NULL                                                          \
      |        ^~
readelf.c:761:9: note: in expansion of macro 'SECTION_NAME_VALID'
  761 |     if (SECTION_NAME_VALID (filedata->section_headers + i)
      |         ^~~~~~~~~~~~~~~~~~

This will likely be fixed in gcc, but inline functions are nicer than
macros.

* readelf.c (SECTION_NAME, SECTION_NAME_VALID),
(SECTION_NAME_PRINT, VALID_SYMBOL_NAME, VALID_DYNAMIC_NAME),
(GET_DYNAMIC_NAME): Delete.  Replace with..
(section_name, section_name_valid, section_name_print),
(valid_symbol_name, valid_dynamic_name, get_dynamic_name): ..these
new inline functions.  Update use throughout file.
binutils/readelf.c