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]

[RFA:] test-case for relocs for linkonce-excluded sections don't become zero, causing g++ EH failure


I started this writeup as a bug report for gcc, but it turns out
to be a bug in binutils.  Relocs for linkonce-excluded sections
don't become zero, as gcc expects, and as happens in binutils
2.9.5/Debian 2.2, 2.9.5.0.22/RH 6.2 but not in "current" CVS for
ix86 -- and worse, for CRIS too. ;-)  This bug should be fixed
before 2.12 in all ports serving a gcc port using DWARF 2 EH, or
people will not be able to use C++ and exceptions, or will be
forced to configure gcc with --enable-sjlj-exceptions.

Perhaps the gcc EH FDE-sorting machinery is too brittle, and
should handle duplicate FDE entries (removing those with the
same pc but higher addresses after sorting), but that's a
slightly different story.

See test-case files x.s and y.s for the story.  For the failing
ports, you'll see in ld.log:

somewhere/../binutils/objdump  -s tmpdir/dump > tmpdir/dump.out
regexp_diff match failure
regexp "^ 2010 100a0000 04000000 66600000 00000000  .*$"
line   " 2010 100a0000 04000000 66600000 080a0000  ........f`......"
XFAIL: ld-linkonce/zeroehl32

Ok to commit test-case?
Or should I make it CRIS-specific and add ld/testsuite/ld-cris?

ld/testsuite:

	* ld-linkonce/linkonce.exp: New file.
	* ld-linkonce/x.s, ld-linkonce/y.s, ld-linkonce/zeroeh.ld,
	ld-linkonce/zeroehl32.d: New test.

diff -cprN none/linkonce.exp ld-linkonce/linkonce.exp
*** none/linkonce.exp	Thu Jan  1 01:00:00 1970
--- ld-linkonce/linkonce.exp	Fri Sep 28 23:46:58 2001
***************
*** 0 ****
--- 1,35 ----
+ # Expect script for ld linkonce tests
+ #   Copyright 2001 Free Software Foundation, Inc.
+ #
+ # This file is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ #
+ # Written by Hans-Peter Nilsson (hp@axis.com)
+ #
+ 
+ # Test for ELF here (or really, .gnu.linkonce functionality), so we don't
+ # have to qualify on ELF specifically in every .d-file.
+ 
+ if { ![istarget *-*-linux*] && ![istarget *-*-gnu] && ![istarget *-*-elf] } {
+     return
+ }
+ 
+ load_lib ld-lib.exp
+ 
+ set rd_test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+ for { set i 0 } { $i < [llength $rd_test_list] } { incr i } {
+     # We need to strip the ".d", but can leave the dirname.
+     verbose [file rootname [lindex $rd_test_list $i]]
+     run_dump_test [file rootname [lindex $rd_test_list $i]]
+ }
diff -cprN none/x.s ld-linkonce/x.s
*** none/x.s	Thu Jan  1 01:00:00 1970
--- ld-linkonce/x.s	Fri Sep 28 23:23:27 2001
***************
*** 0 ****
--- 1,26 ----
+ ;# Main file, x.s, with the program (_start) referring to two
+ ;# linkonce functions fn and fn2.  The functions fn and fn2 are
+ ;# supposed to be equivalent of C++ template instantiations; the
+ ;# main file instantiates fn.  There's the equivalent of an FDE
+ ;# entry in .eh_frame, referring to fn via a local label.
+ 
+  .text
+  .global _start
+ _start:
+  .long fn
+  .long fn2
+ 
+  .section .gnu.linkonce.t.fn,"ax",@progbits
+  .weak fn
+  .type fn,@function
+ fn:
+ .La:
+  .long 1
+  .long 2
+ .Lb:
+  .size fn,.Lb-.La
+ 
+  .section .eh_frame,"aw",@progbits
+  .long 2
+  .long .La
+  .long .Lb-.La
diff -cprN none/y.s ld-linkonce/y.s
*** none/y.s	Thu Jan  1 01:00:00 1970
--- ld-linkonce/y.s	Fri Sep 28 23:24:48 2001
***************
*** 0 ****
--- 1,33 ----
+ ;# Library file y.s has linkonce entries for fn and fn2.  Note
+ ;# that this version of fn has different code, as if compiled
+ ;# with different optimization flags than the one in x.s (not
+ ;# important for this test, though).  The reference from
+ ;# .eh_frame to the linkonce-excluded fn2 must be zero, or g++
+ ;# EH will not work.
+ 
+  .section .gnu.linkonce.t.fn2,"ax",@progbits
+  .weak fn2
+  .type fn2,@function
+ fn2:
+ .Lc:
+  .long 3
+ .Ld:
+  .size fn2,.Ld-.Lc
+ 
+  .section .gnu.linkonce.t.fn,"ax",@progbits
+  .weak fn
+  .type fn,@function
+ fn:
+ .Le:
+  .long 4
+ .Lf:
+  .size fn,.Lf-.Le
+ 
+  .section .eh_frame,"aw",@progbits
+  .long 7
+  .long .Lc
+  .long .Ld-.Lc
+ 
+  .long 0x6066
+  .long .Le
+  .long .Lf-.Le
diff -cprN none/zeroeh.ld ld-linkonce/zeroeh.ld
*** none/zeroeh.ld	Thu Jan  1 01:00:00 1970
--- ld-linkonce/zeroeh.ld	Fri Sep 28 23:32:06 2001
***************
*** 0 ****
--- 1,4 ----
+ SECTIONS {
+  .text 0xa00 : { *(.text); *(.gnu.linkonce.t.*) }
+  .eh_frame 0x2000 : { *(.eh_frame) }
+ }
diff -cprN none/zeroehl32.d ld-linkonce/zeroehl32.d
*** none/zeroehl32.d	Thu Jan  1 01:00:00 1970
--- ld-linkonce/zeroehl32.d	Fri Sep 28 23:52:01 2001
***************
*** 0 ****
--- 1,19 ----
+ #source: x.s
+ #source: y.s
+ #ld: -Ttext 0xa00 -T $srcdir/$subdir/zeroeh.ld
+ #objdump: -s
+ #target: cris-*-elf cris-*-linux* i?86-*-elf i?86-*-linux*
+ #xfail: *-*-*
+ 
+ # The word at address 201c, for the linkonce-excluded section, must be zero.
+ 
+ .*:     file format elf32.*
+ 
+ Contents of section \.text:
+  0a00 080a0000 100a0000 01000000 02000000  .*
+  0a10 03000000                             .*
+ Contents of section \.eh_frame:
+  2000 02000000 080a0000 08000000 07000000  .*
+  2010 100a0000 04000000 66600000 00000000  .*
+  2020 04000000                             .*
+ #pass

brgds, H-P


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