This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Testcases for strip vs group signature symbols
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sourceware dot org
- Date: Thu, 14 Sep 2006 13:31:47 -0700
- Subject: PATCH: Testcases for strip vs group signature symbols
- References: <20060913150800.GH22690@bubble.grove.modra.org>
On Thu, Sep 14, 2006 at 12:38:00AM +0930, Alan Modra wrote:
> Makes strip --strip-unneeded on relocatable object files keep group
> signature symbols.
>
Here is a patch to add 2 testcases. It also fixed a bug in
group_signature. BFD symbol table doesn't include the firsy entry in
ELF symbol table.
H.J.
----
binutils/
2006-09-14 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/3182
* objcopy.c (group_signature): Return proper group signature.
binutils/testsuite/
2006-09-14 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/3182
* binutils-all/objcopy.exp: Run strip-1 and strip-2 for ELF
targets.
* binutils-all/strip-1.d: New file.
* binutils-all/strip-2.d: Likewise.
* lib/utils-lib.exp (run_dump_test): Support strip.
--- binutils/objcopy.c.group 2006-09-14 12:13:45.000000000 -0700
+++ binutils/objcopy.c 2006-09-14 13:05:45.000000000 -0700
@@ -804,7 +804,7 @@ group_signature (asection *group)
if (symhdr->sh_type == SHT_SYMTAB
&& ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
- return isympp[ghdr->sh_info];
+ return isympp[ghdr->sh_info - 1];
}
return NULL;
}
--- binutils/testsuite/binutils-all/objcopy.exp.group 2006-06-23 14:48:14.000000000 -0700
+++ binutils/testsuite/binutils-all/objcopy.exp 2006-09-14 12:40:45.000000000 -0700
@@ -731,5 +731,7 @@ run_dump_test "copy-3"
if [is_elf_format] {
run_dump_test "localize-hidden-1"
+ run_dump_test "strip-1"
+ run_dump_test "strip-2"
}
run_dump_test "localize-hidden-2"
--- binutils/testsuite/binutils-all/strip-1.d.group 2006-09-14 12:39:52.000000000 -0700
+++ binutils/testsuite/binutils-all/strip-1.d 2006-09-14 13:16:53.000000000 -0700
@@ -0,0 +1,11 @@
+#PROG: strip
+#source: group.s
+#readelf: -Sg --wide
+#name: strip with section group 1
+
+#...
+ \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AX[ \t]+.*
+#...
+ \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WA[ \t]+.*
+#...
+There are no section groups in this file.
--- binutils/testsuite/binutils-all/strip-2.d.group 2006-09-14 12:40:12.000000000 -0700
+++ binutils/testsuite/binutils-all/strip-2.d 2006-09-14 13:16:57.000000000 -0700
@@ -0,0 +1,18 @@
+#PROG: strip
+#source: group.s
+#strip: --strip-unneeded
+#readelf: -Sg --wide
+#name: strip with section group 2
+
+#...
+ \[[ 0-9]+\] foo_group[ \t]+GROUP[ \t]+.*
+#...
+ \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AXG[ \t]+.*
+#...
+ \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WAG[ \t]+.*
+#...
+COMDAT group section \[[ 0-9]+\] `foo_group' \[foo_group\] contains 2 sections:
+ \[Index\] Name
+ \[[ 0-9]+\] .text.*
+ \[[ 0-9]+\] .data.*
+#pass
--- binutils/testsuite/lib/utils-lib.exp.group 2006-04-26 07:57:57.000000000 -0700
+++ binutils/testsuite/lib/utils-lib.exp 2006-09-14 12:36:07.000000000 -0700
@@ -279,8 +279,8 @@ proc exe_ext {} {
proc run_dump_test { name {extra_options {}} } {
global subdir srcdir
- global OBJDUMP NM OBJCOPY READELF
- global OBJDUMPFLAGS NMFLAGS OBJCOPYFLAGS READELFFLAGS
+ global OBJDUMP NM OBJCOPY READELF STRIP
+ global OBJDUMPFLAGS NMFLAGS OBJCOPYFLAGS READELFFLAGS STRIPFLAGS
global host_triplet
global env
global copyfile
@@ -362,11 +362,15 @@ proc run_dump_test { name {extra_options
return
}
+ set destopt ""
switch -- $opts(PROG) {
ar { set program ar }
objcopy { set program objcopy }
ranlib { set program ranlib }
- strip { set program strip }
+ strip {
+ set program strip
+ set destopt "-o"
+ }
strings { set program strings }
default {
perror "unrecognized program option $opts(PROG) in $file.d"
@@ -470,7 +474,7 @@ proc run_dump_test { name {extra_options
eval set progopts \$[string toupper $program]FLAGS
eval set binary \$[string toupper $program]
- set exec_output [binutils_run $binary "$progopts $progopts1 $tempfile ${copyfile}.o"]
+ set exec_output [binutils_run $binary "$progopts $progopts1 $tempfile $destopt ${copyfile}.o"]
if ![string match "" $exec_output] {
send_log "$exec_output\n"
verbose "$exec_output"