]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
This commit was manufactured by cvs2svn to create branch 'binutils-
authornobody <>
Tue, 13 Oct 2009 21:17:44 +0000 (21:17 +0000)
committernobody <>
Tue, 13 Oct 2009 21:17:44 +0000 (21:17 +0000)
2_20-branch'.

Cherrypick from master 2009-10-13 21:17:43 UTC Sriraman Tallam <tmsriram@google.com> ' * gc.h (gc_process_relocs): Check if icf is enabled using new':
    gold/testsuite/icf_safe_test.cc
    gold/testsuite/icf_safe_test.sh
    gold/testsuite/retain_symbols_file_test.sh
    gold/testsuite/searched_file_test.cc
    gold/testsuite/searched_file_test_lib.cc
    gold/testsuite/split_i386.sh
    gold/testsuite/split_i386_1.s
    gold/testsuite/split_i386_2.s
    gold/testsuite/split_i386_3.s
    gold/testsuite/split_i386_4.s
    gold/testsuite/split_i386_n.s
    gold/testsuite/split_x86_64.sh
    gold/testsuite/split_x86_64_1.s
    gold/testsuite/split_x86_64_2.s
    gold/testsuite/split_x86_64_3.s
    gold/testsuite/split_x86_64_4.s
    gold/testsuite/split_x86_64_n.s

17 files changed:
gold/testsuite/icf_safe_test.cc [new file with mode: 0644]
gold/testsuite/icf_safe_test.sh [new file with mode: 0755]
gold/testsuite/retain_symbols_file_test.sh [new file with mode: 0755]
gold/testsuite/searched_file_test.cc [new file with mode: 0644]
gold/testsuite/searched_file_test_lib.cc [new file with mode: 0644]
gold/testsuite/split_i386.sh [new file with mode: 0755]
gold/testsuite/split_i386_1.s [new file with mode: 0644]
gold/testsuite/split_i386_2.s [new file with mode: 0644]
gold/testsuite/split_i386_3.s [new file with mode: 0644]
gold/testsuite/split_i386_4.s [new file with mode: 0644]
gold/testsuite/split_i386_n.s [new file with mode: 0644]
gold/testsuite/split_x86_64.sh [new file with mode: 0755]
gold/testsuite/split_x86_64_1.s [new file with mode: 0644]
gold/testsuite/split_x86_64_2.s [new file with mode: 0644]
gold/testsuite/split_x86_64_3.s [new file with mode: 0644]
gold/testsuite/split_x86_64_4.s [new file with mode: 0644]
gold/testsuite/split_x86_64_n.s [new file with mode: 0644]

diff --git a/gold/testsuite/icf_safe_test.cc b/gold/testsuite/icf_safe_test.cc
new file mode 100644 (file)
index 0000000..9e8a369
--- /dev/null
@@ -0,0 +1,54 @@
+// icf_safe_test.cc -- a test case for gold
+
+// Copyright 2009 Free Software Foundation, Inc.
+// Written by Sriraman Tallam <tmsriram@google.com>.
+
+// This file is part of gold.
+
+// This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// The goal of this program is to verify if identical code folding
+// in safe mode correctly folds only ctors and dtors. kept_func_1 must
+// not be folded into kept_func_2.  The ctor and dtor of class A must
+// be folded.
+
+class A
+{
+  public:
+    A()
+    {
+    }
+    ~A()
+    {
+    }
+};
+
+A a;
+
+int kept_func_1()
+{
+  return 1;
+}
+
+int kept_func_2()
+{
+  return 1;
+}
+
+int main()
+{
+  return 0;
+}
diff --git a/gold/testsuite/icf_safe_test.sh b/gold/testsuite/icf_safe_test.sh
new file mode 100755 (executable)
index 0000000..f77559c
--- /dev/null
@@ -0,0 +1,50 @@
+# icf_safe_test.sh -- test --icf=safe
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Sriraman Tallam <tmsriram@google.com>.
+
+# This file is part of gold.
+
+# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The goal of this program is to verify if --icf=safe  works as expected.
+# File icf_safe_test.cc is in this test. This program checks if only
+# ctors and dtors are folded.
+
+check_nofold()
+{
+    func_addr_1=`grep $2 $1 | awk '{print $1}'`
+    func_addr_2=`grep $3 $1 | awk '{print $1}'`
+    if [ $func_addr_1 = $func_addr_2 ]
+    then
+        echo "Safe Identical Code Folding folded" $2 "and" $3
+       exit 1
+    fi
+}
+
+check_fold()
+{
+    func_addr_1=`grep $2 $1 | awk '{print $1}'`
+    func_addr_2=`grep $3 $1 | awk '{print $1}'`
+    if [ $func_addr_1 != $func_addr_2 ]
+    then
+        echo "Safe Identical Code Folding did not fold " $2 "and" $3
+       exit 1
+    fi
+}
+
+check_nofold icf_safe_test.stdout "kept_func_1" "kept_func_2"
+check_fold   icf_safe_test.stdout "_ZN1AD1Ev" "_ZN1AC1Ev"
diff --git a/gold/testsuite/retain_symbols_file_test.sh b/gold/testsuite/retain_symbols_file_test.sh
new file mode 100755 (executable)
index 0000000..e0d3ffc
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# retain_symbols_file_test.sh -- a test case for -retain-symbols-file
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Craig Silverstein <csilvers@google.com>.
+
+# This file is part of gold.
+
+# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The Makefile tries linking simple_test.o with -retain-symbols-file.
+# It then runs nm over the results.  We check that the output is right.
+
+check_present()
+{
+    if ! grep -q "$1" retain_symbols_file_test.stdout
+    then
+        echo "Did not find expected symbol $1 in retain_symbols_file_test.stdout"
+        exit 1
+    fi
+}
+
+check_absent()
+{
+    if grep -q "$1" retain_symbols_file_test.stdout
+    then
+        echo "Found unexpected symbol $1 in retain_symbols_file_test.stdout"
+        exit 1
+    fi
+}
+
+check_present 't1'
+check_present 't16b::t16b()'
+check_present 't20a::get()'
+check_present 't18()'
+check_absent 't10'
+check_absent 't1()'
+check_absent 't16b::t()'
+
+exit 0
diff --git a/gold/testsuite/searched_file_test.cc b/gold/testsuite/searched_file_test.cc
new file mode 100644 (file)
index 0000000..aa99e24
--- /dev/null
@@ -0,0 +1,36 @@
+// searched_file_test.cc -- test -l:foo.a for gold
+
+// Copyright 2009 Free Software Foundation, Inc.
+// Written by Chris Demetriou <cgd@google.com>.
+
+// This file is part of gold.
+
+// This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// The Linux kernel builds an object file using a linker script, and
+// then links against that object file using the -R option.  This is a
+// test for that usage.
+
+#include <cstdlib>
+
+extern int zero_from_lib;
+        
+int
+main(int, char**)
+{
+  exit(zero_from_lib);
+}
+
diff --git a/gold/testsuite/searched_file_test_lib.cc b/gold/testsuite/searched_file_test_lib.cc
new file mode 100644 (file)
index 0000000..0686e52
--- /dev/null
@@ -0,0 +1,27 @@
+// searched_file_test_lib.cc -- test -l:foo.a for gold
+
+// Copyright 2009 Free Software Foundation, Inc.
+// Written by Chris Demetriou <cgd@google.com>.
+
+// This file is part of gold.
+
+// This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// The Linux kernel builds an object file using a linker script, and
+// then links against that object file using the -R option.  This is a
+// test for that usage.
+
+int zero_from_lib = 0;
diff --git a/gold/testsuite/split_i386.sh b/gold/testsuite/split_i386.sh
new file mode 100755 (executable)
index 0000000..e94fea2
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# split_i386.sh -- test -fstack-split for i386
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Ian Lance Taylor <iant@google.com>.
+
+# This file is part of gold.
+
+# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+match()
+{
+  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+    echo 1>&2 "could not find '$1' in $2"
+    exit 1
+  fi
+}
+
+nomatch()
+{
+  if egrep "$1" "$2" >/dev/null 2>&1; then
+    echo 1>&2 "found unexpected '$1' in $2"
+    exit 1
+  fi
+}
+
+match 'cmp.*+%gs:[^,]*,%esp' split_i386_1.stdout
+match 'call.*__morestack>?$' split_i386_1.stdout
+match 'lea.*-0x200\(%esp\),' split_i386_1.stdout
+
+match 'stc' split_i386_2.stdout
+match 'call.*__morestack_non_split>?$' split_i386_2.stdout
+nomatch 'call.*__morestack>?$' split_i386_2.stdout
+match 'lea.*-0x4200\(%esp\),' split_i386_2.stdout
+
+match 'failed to match' split_i386_3.stdout
+
+match 'call.*__morestack>?$' split_i386_4.stdout
+
+match 'cannot mix' split_i386_r.stdout
diff --git a/gold/testsuite/split_i386_1.s b/gold/testsuite/split_i386_1.s
new file mode 100644 (file)
index 0000000..9ac816e
--- /dev/null
@@ -0,0 +1,33 @@
+# split_i386_1.s: i386 specific test case for -fsplit-stack.
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       cmp     %gs:0x30,%esp
+       jae     1f
+       call    __morestack
+       ret
+1:
+       call    fn2
+       ret
+
+       .size   fn1,. - fn1
+
+       .global fn2
+       .type   fn2,@function
+fn2:
+       lea     -0x200(%esp),%ecx
+       cmp     %gs:0x30,%ecx
+       jae     1f
+       call    __morestack
+       ret
+1:
+       call    fn1
+       ret
+
+       .size   fn2,. - fn2
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
diff --git a/gold/testsuite/split_i386_2.s b/gold/testsuite/split_i386_2.s
new file mode 100644 (file)
index 0000000..b4a2f14
--- /dev/null
@@ -0,0 +1,33 @@
+# split_i386_2.s: i386 specific, -fsplit-stack calling non-split
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       cmp     %gs:0x30,%esp
+       jae     1f
+       call    __morestack
+       ret
+1:
+       call    fn3
+       ret
+
+       .size   fn1,. - fn1
+
+       .global fn2
+       .type   fn2,@function
+fn2:
+       lea     -0x200(%esp),%ecx
+       cmp     %gs:0x30,%ecx
+       jae     1f
+       call    __morestack
+       ret
+1:
+       call    fn3
+       ret
+
+       .size   fn2,. - fn2
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
diff --git a/gold/testsuite/split_i386_3.s b/gold/testsuite/split_i386_3.s
new file mode 100644 (file)
index 0000000..fdde7a9
--- /dev/null
@@ -0,0 +1,22 @@
+# split_i386_3.s: i386 specific, adjustment failure
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       push    %ebp
+       mov     %esp,%ebp
+       cmp     %gs:0x30,%esp
+       jae     1f
+       call    __morestack
+       ret
+1:
+       call    fn3
+       leave
+       ret
+
+       .size   fn1,. - fn1
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
diff --git a/gold/testsuite/split_i386_4.s b/gold/testsuite/split_i386_4.s
new file mode 100644 (file)
index 0000000..be774ae
--- /dev/null
@@ -0,0 +1,23 @@
+# split_i386_4.s: i386 specific, permitted adjustment failure
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       push    %ebp
+       mov     %esp,%ebp
+       cmp     %gs:0x30,%esp
+       jae     1f
+       call    __morestack
+       ret
+1:
+       call    fn3
+       leave
+       ret
+
+       .size   fn1,. - fn1
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
+       .section        .note.GNU-no-split-stack,"",@progbits
diff --git a/gold/testsuite/split_i386_n.s b/gold/testsuite/split_i386_n.s
new file mode 100644 (file)
index 0000000..4d4e6e8
--- /dev/null
@@ -0,0 +1,12 @@
+# split_i386_n.s: i386 specific, -fsplit-stack calling non-split
+
+       .text
+
+       .global fn3
+       .type   fn3,@function
+fn3:
+       ret
+
+       .size   fn3,. - fn3
+
+       .section        .note.GNU-stack,"",@progbits
diff --git a/gold/testsuite/split_x86_64.sh b/gold/testsuite/split_x86_64.sh
new file mode 100755 (executable)
index 0000000..61544b2
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# split_x86_64.sh -- test -fstack-split for x86_64
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Ian Lance Taylor <iant@google.com>.
+
+# This file is part of gold.
+
+# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+match()
+{
+  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+    echo 1>&2 "could not find '$1' in $2"
+    exit 1
+  fi
+}
+
+nomatch()
+{
+  if egrep "$1" "$2" >/dev/null 2>&1; then
+    echo 1>&2 "found unexpected '$1' in $2"
+    exit 1
+  fi
+}
+
+match 'cmp.*+%fs:[^,]*,%rsp' split_x86_64_1.stdout
+match 'callq.*__morestack>?$' split_x86_64_1.stdout
+match 'lea.*-0x200\(%rsp\),' split_x86_64_1.stdout
+
+match 'stc' split_x86_64_2.stdout
+match 'callq.*__morestack_non_split>?$' split_x86_64_2.stdout
+nomatch 'callq.*__morestack>?$' split_x86_64_2.stdout
+match 'lea.*-0x4200\(%rsp\),' split_x86_64_2.stdout
+
+match 'failed to match' split_x86_64_3.stdout
+
+match 'callq.*__morestack>?$' split_x86_64_4.stdout
+
+match 'cannot mix' split_x86_64_r.stdout
diff --git a/gold/testsuite/split_x86_64_1.s b/gold/testsuite/split_x86_64_1.s
new file mode 100644 (file)
index 0000000..e23ea7f
--- /dev/null
@@ -0,0 +1,33 @@
+# split_x86_64_1.s: x86_64 specific test case for -fsplit-stack.
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       cmp     %fs:0x70,%rsp
+       jae     1f
+       callq   __morestack
+       retq
+1:
+       callq   fn2
+       retq
+
+       .size   fn1,. - fn1
+
+       .global fn2
+       .type   fn2,@function
+fn2:
+       lea     -0x200(%rsp),%r10
+       cmp     %fs:0x70,%r10
+       jae     1f
+       callq   __morestack
+       retq
+1:
+       callq   fn1
+       retq
+
+       .size   fn2,. - fn2
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
diff --git a/gold/testsuite/split_x86_64_2.s b/gold/testsuite/split_x86_64_2.s
new file mode 100644 (file)
index 0000000..0559bbc
--- /dev/null
@@ -0,0 +1,33 @@
+# split_x86_64_2.s: x86_64 specific, -fsplit-stack calling non-split
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       cmp     %fs:0x70,%rsp
+       jae     1f
+       callq   __morestack
+       retq
+1:
+       callq   fn3
+       retq
+
+       .size   fn1,. - fn1
+
+       .global fn2
+       .type   fn2,@function
+fn2:
+       lea     -0x200(%rsp),%r10
+       cmp     %fs:0x70,%r10
+       jae     1f
+       callq   __morestack
+       retq
+1:
+       callq   fn3
+       retq
+
+       .size   fn2,. - fn2
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
diff --git a/gold/testsuite/split_x86_64_3.s b/gold/testsuite/split_x86_64_3.s
new file mode 100644 (file)
index 0000000..68ae6e3
--- /dev/null
@@ -0,0 +1,22 @@
+# split_x86_64_3.s: x86_64 specific, adjustment failure
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       push    %rbp
+       mov     %rsp,%rbp
+       cmp     %fs:0x70,%rsp
+       jae     1f
+       callq   __morestack
+       retq
+1:
+       callq   fn3
+       leaveq
+       retq
+
+       .size   fn1,. - fn1
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
diff --git a/gold/testsuite/split_x86_64_4.s b/gold/testsuite/split_x86_64_4.s
new file mode 100644 (file)
index 0000000..653b917
--- /dev/null
@@ -0,0 +1,23 @@
+# split_x86_64_4.s: x86_64 specific, permitted adjustment failure
+
+       .text
+
+       .global fn1
+       .type   fn1,@function
+fn1:
+       push    %rbp
+       mov     %rsp,%rbp
+       cmp     %fs:0x70,%rsp
+       jae     1f
+       callq   __morestack
+       retq
+1:
+       callq   fn3
+       leaveq
+       retq
+
+       .size   fn1,. - fn1
+
+       .section        .note.GNU-stack,"",@progbits
+       .section        .note.GNU-split-stack,"",@progbits
+       .section        .note.GNU-no-split-stack,"",@progbits
diff --git a/gold/testsuite/split_x86_64_n.s b/gold/testsuite/split_x86_64_n.s
new file mode 100644 (file)
index 0000000..10436b1
--- /dev/null
@@ -0,0 +1,12 @@
+# split_x86_64_n.s: x86_64 specific, -fsplit-stack calling non-split
+
+       .text
+
+       .global fn3
+       .type   fn3,@function
+fn3:
+       retq
+
+       .size   fn3,. - fn3
+
+       .section        .note.GNU-stack,"",@progbits