This is the mail archive of the binutils@sourceware.org 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] Fix C++ no .eh_frame_hdr table will be created (PR 6893)


Hi Nick,

On Thu, 18 Sep 2008 09:15:56 +0200, Nick Clifton wrote:
>>> -if ![is_elf_format] {
>>> +if { ![is_elf_format] \
>>> +     || (![istarget i?86-*-linux*] \
>>> +	 && ![istarget powerpc*-*-linux*] \
>>> +	 && ![istarget s390*-*-linux*] \
>>> +	 && ![istarget x86_64-*-linux*]) } {
>>
>> There are more targets supporting cfi (all those that define
>> TARGET_USE_CFIPOP).
>
> If this test is needed for more than just one file then we ought to move  
> it into ld/testsuite/lib/ld-lib.exp so that bug fixes and additions can  
> be added in just one place.

Originally I just copied the style I saw there.  Here is the general framework
for CFI tests.
Tested on: {alpha,arm,m68k,i386,ppc,sh,s390,sparc,hppa,mips}-linux

2.19 should IMO get only the ia64-fixing patch:
	http://sourceware.org/ml/binutils/2008-09/msg00138.html


Thanks,
Jan
2008-09-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Provide virtual target "cfi" for targets supporting CFI.
	* ld-elf/eh-frame-hdr.d: Replace target and xfail statements by single
	`target: cfi'.
	* ld-elf/eh-group.exp: Call check_as_cfi instead of is_elf_format.
	* ld-elf/eh-group1.s, elf/eh-group2.s: Use more compatible section
	flags prefix '%'.
	* ld-elf/eh5.d: Replace target statement by `target: cfi'.  Relax the
	`Code alignment factor' matching.
	* lib/ld-lib.exp: Rename istarget as istarget_ld.
	(istarget, check_as_cfi): New procedure.
	(run_dump_test): New comment for the virtual target `cfi'.

--- ld/testsuite/ld-elf/eh-frame-hdr.d	4 Dec 2006 08:57:09 -0000	1.1
+++ ld/testsuite/ld-elf/eh-frame-hdr.d	18 Sep 2008 20:40:59 -0000
@@ -1,17 +1,7 @@
 #source: eh-frame-hdr.s
 #ld: -e _start --eh-frame-hdr
 #objdump: -hw
-#target: alpha*-*-*
-#target: arm*-*-*
-#target: i?86-*-*
-#target: m68k-*-*
-#target: mips*-*-*
-#target: powerpc*-*-*
-#target: s390*-*-*
-#target: sh*-*-*
-#xfail: sh*l*-*-*
-#target: sparc*-*-*
-#target: x86_64-*-*
+#target: cfi
 #...
   [0-9] .eh_frame_hdr 0*[12][048c] .*
 #pass
--- ld/testsuite/ld-elf/eh-group.exp	17 Sep 2008 07:50:29 -0000	1.1
+++ ld/testsuite/ld-elf/eh-group.exp	18 Sep 2008 20:40:59 -0000
@@ -29,9 +29,9 @@
 # executable trying to create .eh_frame_hdr.  It needs a separate .exp file due
 # to the requirement of two `ld' runs.
 
-# Exclude non-ELF targets.
+# Exclude non-CFI (such as ia64) targets.
 
-if ![is_elf_format] {
+if {![check_as_cfi]} {
     return
 }
 
--- ld/testsuite/ld-elf/eh-group1.s	17 Sep 2008 07:50:29 -0000	1.1
+++ ld/testsuite/ld-elf/eh-group1.s	18 Sep 2008 20:40:59 -0000
@@ -1,4 +1,4 @@
-	.section	sect, "axG", @progbits, sectgroup, comdat
+	.section	sect, "axG", %progbits, sectgroup, comdat
 	.global	_start
 _start:
 	.cfi_startproc
--- ld/testsuite/ld-elf/eh-group2.s	17 Sep 2008 07:50:29 -0000	1.1
+++ ld/testsuite/ld-elf/eh-group2.s	18 Sep 2008 20:40:59 -0000
@@ -1,4 +1,4 @@
-	.section	sect, "axG", @progbits, sectgroup, comdat
+	.section	sect, "axG", %progbits, sectgroup, comdat
 	.cfi_startproc
 	.skip 16
 	.cfi_endproc
--- ld/testsuite/ld-elf/eh5.d	28 Jan 2008 15:15:32 -0000	1.2
+++ ld/testsuite/ld-elf/eh5.d	18 Sep 2008 20:40:59 -0000
@@ -3,14 +3,14 @@
 #source: eh5b.s
 #ld:
 #readelf: -wf
-#target: x86_64-*-* i?86-*-*
+#target: cfi
 
 The section .eh_frame contains:
 
 00000000 0000001[04] 00000000 CIE
   Version:               1
   Augmentation:          "zR"
-  Code alignment factor: 1
+  Code alignment factor: .*
   Data alignment factor: .*
   Return address column: .*
   Augmentation data:     1b
@@ -29,7 +29,7 @@ The section .eh_frame contains:
 000000(2c|30) 00000014 00000000 CIE
   Version:               1
   Augmentation:          "zPR"
-  Code alignment factor: 1
+  Code alignment factor: .*
   Data alignment factor: .*
   Return address column: .*
   Augmentation data:     03 .. .. .. .. 1b
@@ -53,7 +53,7 @@ The section .eh_frame contains:
 0000007[48] 0000001[8c] 00000000 CIE
   Version:               1
   Augmentation:          "zPLR"
-  Code alignment factor: 1
+  Code alignment factor: .*
   Data alignment factor: .*
   Return address column: .*
   Augmentation data:     03 .. .. .. .. 0c 1b
@@ -74,7 +74,7 @@ The section .eh_frame contains:
 000000b[08] 0000001[04] 00000000 CIE
   Version:               1
   Augmentation:          "zR"
-  Code alignment factor: 1
+  Code alignment factor: .*
   Data alignment factor: .*
   Return address column: .*
   Augmentation data:     1b
@@ -89,7 +89,7 @@ The section .eh_frame contains:
 000000[de]8 00000014 00000000 CIE
   Version:               1
   Augmentation:          "zPR"
-  Code alignment factor: 1
+  Code alignment factor: .*
   Data alignment factor: .*
   Return address column: .*
   Augmentation data:     03 .. .. .. .. 1b
@@ -111,7 +111,7 @@ The section .eh_frame contains:
 000001(1c|30) 0000001[8c] 00000000 CIE
   Version:               1
   Augmentation:          "zPLR"
-  Code alignment factor: 1
+  Code alignment factor: .*
   Data alignment factor: .*
   Return address column: .*
   Augmentation data:     03 .. .. .. .. 0c 1b
--- ld/testsuite/lib/ld-lib.exp	18 Feb 2008 11:04:09 -0000	1.54
+++ ld/testsuite/lib/ld-lib.exp	18 Sep 2008 20:41:01 -0000
@@ -598,7 +598,8 @@ proc simple_diff { file_1 file_2 } {
 #
 #   target: TARGET
 #       Only run the test for TARGET.  This may occur more than once; the
-#       target being tested must match at least one.
+#       target being tested must match at least one.  You may provide target
+#       name "cfi" for any target supporting the CFI statements.
 #
 #   notarget: TARGET
 #       Do not run the test for TARGET.  This may occur more than once;
@@ -1569,3 +1570,39 @@ proc check_gc_sections_available { } {
     }
     return $gc_sections_available_saved
 }
+
+# Check if the assembler supports CFI statements.
+
+proc check_as_cfi { } {
+    global check_as_cfi_result
+    global as
+    if [info exists check_as_cfi_result] {
+	return $check_as_cfi_result
+    }
+    set as_file "tmpdir/check_as_cfi.s"
+    set as_fh [open $as_file w 0666]
+    puts $as_fh "# Generated file. DO NOT EDIT"
+    puts $as_fh "\t.cfi_startproc"
+    puts $as_fh "\t.cfi_endproc"
+    close $as_fh
+    remote_download host $as_file
+    verbose -log "Checking CFI support:"
+    rename "perror" "check_as_cfi_perror"
+    proc perror { args } { }
+    set success [ld_assemble $as $as_file "/dev/null"]
+    rename "perror" ""
+    rename "check_as_cfi_perror" "perror"
+    #remote_file host delete $as_file
+    set check_as_cfi_result $success
+    return $success
+}
+
+# Provide virtual target "cfi" for targets supporting CFI.
+
+rename "istarget" "istarget_ld"
+proc istarget { target } {
+    if {$target == "cfi"} {
+	return [check_as_cfi]
+    }
+    return [istarget_ld $target]
+}

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