[PATCH v2] elf: Handle the section flag 'o' linked to special sections

H.J. Lu hjl.tools@gmail.com
Mon Jan 12 23:55:02 GMT 2026


On Tue, Jan 13, 2026 at 12:59 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 11.01.2026 05:03, H.J. Lu wrote:
> > Call _bfd_elf_section_from_bfd_section to get the sh_link value from
> > the section flag 'o' directive, which may point to special sections,
> > like SHN_ABS or SHN_COMM.  Update readelf to print the special section
> > names in the sh_link field.
>
> In principle okay, but I have a question first:
>
> > binutils/
> >
> > PR gas/33744
> > * readelf.c (special_defined_section_index): New.
> > (get_32bit_section_headers): Don't warn special section indexes
> > in the sh_link field.
> > (get_64bit_section_headers): Likewise.
>
> In these two you adjust (identical) conditions involving
> "internal->sh_link > num". However, here ...
>
> > (process_section_headers): Print special section names.
>
> ... it is "section->sh_link >= filedata->file_header.e_shnum". The latter
> looks correct to me while the former doesn't until switched to also
> using >= . While one could argue this is an unrelated change, imo it
> would better be done while fiddling with this anyway. Thoughts?
>
> Jan

Good point.   Here is the v2 patch to replace "internal->sh_link > num"
with "internal->sh_link >= num".

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-elf-Handle-the-section-flag-o-linked-to-special-s.patch
Type: text/x-patch
Size: 20199 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260113/86209911/attachment-0001.bin>


More information about the Binutils mailing list