This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug in .eh_frame_hdr processing


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]