[PATCH 3/6] bfd: refine handling of relocations between debugging sections
Alan Modra
amodra@gmail.com
Tue Mar 9 11:23:54 GMT 2021
On Tue, Mar 09, 2021 at 08:46:08AM +0100, Jan Beulich wrote:
> On 09.03.2021 03:24, Alan Modra wrote:
> > @@ -1323,6 +1322,19 @@ bfd_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
> > return bfd_reloc_ok;
> > }
> >
> > + /* In some cases the relocation should be treated as input section
> > + relative, as when linking ELF DWARF into PE COFF. Many ELF
> > + targets lack section relative relocations and instead use
> > + ordinary absolute relocations for references between DWARF
> > + sections. That is arguably a bug in those targets but it happens
> > + to work for the usual case of linking to non-loaded ELF debug
> > + sections with VMAs forced to zero. PE COFF on the other hand
> > + doesn't allow a section VMA of zero. */
> > + if (output_bfd == NULL
> > + && (symbol->section->flags & SEC_DEBUGGING) != 0
> > + && (input_section->flags & SEC_DEBUGGING) != 0)
> > + reloc_entry->addend -= symbol->section->output_section->vma;
>
> ... already in your reduced replacement suggestion to my change
> to bfd_perform_relocation() you didn't only drop the "just to
> be on the safe side" checks, but also the pc-relative one. Are
> you sure there aren't any cases where such relocations might be
> used, particularly when the relocation points back to the same
> section?
I'm aware of DW_OP_skip, DW_OP_bra, DW_OP_call[24] that use relative
offsets to the same section. I figured these ought to resolve at
assembly time and thus not have relocations. But I suppose some
targets might emit needless relocs, so yes, I'll put the pc-relative
test back.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list