This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: bug in .eh_frame_hdr processing
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 9 Sep 2003 13:31:32 +0200
- Subject: Re: bug in .eh_frame_hdr processing
- References: <15959.55690.99080.372808@masala.cambridge.redhat.com> <20030223065829.GD535@redhat.com> <15960.43501.654884.532629@cuddles.cambridge.redhat.com> <20030224051118.GY31111@bubble.sa.bigpond.net.au> <15966.21503.394413.466465@masala.cambridge.redhat.com> <20030909022543.GN1443@bubble.modra.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Sep 09, 2003 at 11:55:43AM +0930, Alan Modra wrote:
> At the time this patch went in, I'd forgotten why I enabled eh_frame
> optimization during ld -r. Of course, the problem has raised its ugly
> head again.
>
> The problem being that linux kernel modules written in C++ need to have
> some sort of eh_frame optimization pass to remove info related to
> removed linkonce sections. Otherwise, you end up with relocations
> against the zero index symbol and modutils segfaults. Worse, even if
> modutils is hacked to get around the segfault, I think the unwinder
> would have problems interpreting eh_frame.
>
> I see two ways to fix this problem:
> a) Implement a new option, eg. -z eh_frame_optimize, that runs eh_frame
> optimization for ld -r.
> b) Remove optimizations in elf-eh-frame.c that are unsafe for ld -r, and
> always run eh_frame optimization.
>
> (a) is easy, and justified on the grounds that no further linking will
> be done on a linux kernel module. ie. it's a ld -r that is "final" in
> some sense. (b) is harder, so I'll do (a), unless Jakub reckons he
> knows what should be done for (b).
Part of elf-eh-frame.c relies on the relocation processing done in
*relocate_section. With ld -r such relocation processing doesn't happen,
so (a) is not that easy either.
What IMHO can be done for (a) easily is to turn FDEs against removed
linkonce sections into dummy CIEs nobody will reference.
This means: changing all relocations against addresses within the FDE
into R_*_NONE and setting FDE's payload to
.long 0; .byte 1, 0, 1, 0x7c, 0 and bzero the rest.
This could be done with ld -r always, as elf-eh-frame.c should nuke
unused CIEs during final link.
Jakub