Squash readelf warning on zero sh_link reloc section
On readelf examining a static executable built with current glibc,
we get a silly warning.
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL
0000000000000000 000000 000000 00 0 0 0
[ 1] .note.ABI-tag NOTE
0000000000400190 000190 000020 00 A 0 0 4
[ 2] .note.gnu.build-id NOTE
00000000004001b0 0001b0 000024 00 A 0 0 4
readelf: Warning: [ 3]: Link field (0) should index a symtab section.
[ 3] .rela.plt RELA
00000000004001d8 0001d8 000228 18 AI 0 20 8
This .rela.plt section contains only IRELATIVE relocations (which have
symbol index zero), so it isn't appropriate to warn. A zero sh_link
section is deliberately chosen for such a section (see PR10337 and
PR23850).
So this patch disables the SHT_REL* sh_link warning. I've also
removed the .rel.dyn/.rela.dyn section name test to disable the
sh_info warning for SHT_REL* sections. While relocation sections in
an executable need not specify the section they relocate (the
relocation sh_offset field is an address, not a section offset), that
isn't true in a relocatable file where sh_offset is relative to a
section. If .rela.dyn happens to exist in an ET_REL object it must
specify a valid section.
* readelf.c (process_section_headers): Don't warn on a zero
sh_info or sh_link for any reloc section in an executable or
shared library. Do warn for .rel.dyn/.rela.dyn in ET_REL.