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: PATCH: Linker is broken


On Fri, May 14, 2004 at 05:11:48AM +0200, Jakub Jelinek wrote:
> On Thu, May 13, 2004 at 07:48:06PM -0700, H. J. Lu wrote:
> > The problem is .eh_frame is readonly. The new linker script moves it
> > at the beginning of data segment. When it is empty, the new alignment
> > causes map_sections_to_segments to allocate a segment for an empty
> > .eh_frame section. This patch fixes the testcase. Should
> > map_sections_to_segments be able to deal with empty readonly
> > section at the alignment boundary at the beginning of data segment?
> 
> This patch will break linking if .eh_frame is read-write (e.g. with
> older GCCs, e.g. all GCC 2.x .eh_frames need relocations and are read-write,
> with newer GCCs they are read-write unless configure found it is desirable
> to make them read-only).  Also, .gcc_except_table is another section
> which is sometimes read-only and sometimes read-write.
> 
> The reason why I have never seen such problems is that because I have
> in my rpms also the
> http://sources.redhat.com/ml/binutils/2002-11/msg00592.html
> patch (well, adjusted for current sources), so .eh_frame and
> .gcc_except_table are put into the end of the read-only segment if
> they are read-only and into the read-write segment if they are read-write.
> ...
>   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
>   .rodata1        : { *(.rodata1) }
>   .eh_frame_hdr : { *(.eh_frame_hdr) }
>   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
>   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table) }
>   /* Adjust the address for the data segment.  We want to adjust up to
>      the same address within the page on the next page up.  */
>   . = ALIGN (0x100000) - ((0x100000 - .) & (0x100000 - 1)); . = DATA_SEGMENT_ALIGN (0x100000, 0x1000);
>   /* Exception handling  */
>   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
>   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table) }
>   /* Thread Local Storage sections  */
>   .tdata          : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
>   .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
> ...
> 
> Now, there are several options what to do with CVS:
> 1) put that patch into CVS (if somebody can come up with a nicer
>    syntax, let me know)
> 2) implement what Alan proposed, i.e. AUTOPLACE keyword and hardcode
>    that .eh_frame should come before .gcc_except_table (if any),
>    at the very end of RX segment if read-only and at the very beginning
>    of RW segment if read-write (and similarly for .gcc_except_table)
> 3) do a hack and mark .eh_frame/.gcc_except_table output sections
>    read-write
> 4) somehow deal with read-only sections at the beginning of read-write
>    segment in section to segment mapping code (not sure how though)
> 
> This problem did not pop up in the make check testing I have done
> on CVS binutils with the relro patch applied, I'm sorry for missing
> this problem.
> 

I will create testcases for those problems. In the mean time, I will
apply your patch to my Linux binutils until the problem is properly
fixed.


H.J.


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