summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-07-05 08:58:28 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-10-09 05:44:24 -0700
commit27684d5c6505f50a90358594343882e5e28e1f1b (patch)
tree1ebbf5995db1fde78c45b98307fe22aa587ac2a8
parentb94cb4704526cffc09ea17fa10d6f91276467898 (diff)
downloadgcc-hjl/pr35514.tar.gz
Output ELF symbol type for undefined symbolshjl/pr35514
Update default_elf_asm_output_external to also output symbol type to help ELF linker properly issue diagnostic message. We don't output symbol type for reference to external TLS symbol since assembler will generate TLS symbol type based on TLS relocation and Solaris assembler only supports the @tls_obj type directive, not the @tls_object type directive used by GNU assmbler, which doesn't understand the @tls_obj type directive. gcc/ PR target/35514 * varasm.c (default_elf_asm_output_external): Also output symbol type. gcc/testsuite/ PR target/35514 * g++.dg/fstack-protector-strong.C: Adjust scan-assembler-times for ELF targets. * g++.dg/opt/devirt2.C: Likewise. * g++.dg/pr49718.C: Likewise. * g++.dg/stackprotectexplicit2.C : Likewise. * gcc.dg/fstack-protector-strong.c: Likewise. * gcc.dg/tree-ssa/loop-1.c: Likewise. * gcc.target/i386/memcpy-strategy-3.c: Likewise. * gcc.target/i386/memset-strategy-1.c: Likewise. * gfortran.dg/bind_c_array_params_2.f90: Likewise. * gcc.dg/pr35514-1.c: New file. * gcc.dg/pr35514-2.c: Likewise. * lib/target-supports.exp (check_effective_target_elf): New.
-rw-r--r--gcc/testsuite/g++.dg/fstack-protector-strong.C3
-rw-r--r--gcc/testsuite/g++.dg/opt/devirt2.C3
-rw-r--r--gcc/testsuite/g++.dg/pr49718.C3
-rw-r--r--gcc/testsuite/g++.dg/stackprotectexplicit2.C3
-rw-r--r--gcc/testsuite/gcc.dg/fstack-protector-strong.c3
-rw-r--r--gcc/testsuite/gcc.dg/pr35514-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/pr35514-2.c14
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loop-1.c3
-rw-r--r--gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c3
-rw-r--r--gcc/testsuite/gcc.target/i386/memset-strategy-1.c3
-rw-r--r--gcc/testsuite/gfortran.dg/bind_c_array_params_2.f903
-rw-r--r--gcc/testsuite/lib/target-supports.exp20
-rw-r--r--gcc/varasm.c28
13 files changed, 91 insertions, 14 deletions
diff --git a/gcc/testsuite/g++.dg/fstack-protector-strong.C b/gcc/testsuite/g++.dg/fstack-protector-strong.C
index ae6d2fdb8df..7be72fafb73 100644
--- a/gcc/testsuite/g++.dg/fstack-protector-strong.C
+++ b/gcc/testsuite/g++.dg/fstack-protector-strong.C
@@ -85,4 +85,5 @@ int foo7 (B *p)
return p->return_slot ().a1;
}
-/* { dg-final { scan-assembler-times "stack_chk_fail" 7 } } */
+/* { dg-final { scan-assembler-times "stack_chk_fail" 8 { target elf } } } */
+/* { dg-final { scan-assembler-times "stack_chk_fail" 7 { target { ! elf } } } } */
diff --git a/gcc/testsuite/g++.dg/opt/devirt2.C b/gcc/testsuite/g++.dg/opt/devirt2.C
index cf4842bd4df..0ea54f664db 100644
--- a/gcc/testsuite/g++.dg/opt/devirt2.C
+++ b/gcc/testsuite/g++.dg/opt/devirt2.C
@@ -5,7 +5,8 @@
// { dg-additional-options "-mshort-calls" {target epiphany-*-*} }
// Using -mno-abicalls avoids a R_MIPS_JALR .reloc.
// { dg-additional-options "-mno-abicalls" { target mips*-*-* } }
-// { dg-final { scan-assembler-times "xyzzy" 2 { target { ! { alpha*-*-* hppa*-*-* ia64*-*-hpux* sparc*-*-* *-*-mingw* } } } } }
+// { dg-final { scan-assembler-times "xyzzy" 2 { target { ! elf } && target { ! { alpha*-*-* hppa*-*-* ia64*-*-hpux* sparc*-*-* *-*-mingw* } } } } }
+// { dg-final { scan-assembler-times "xyzzy" 3 { target { elf && { ! { alpha*-*-* hppa*-*-* ia64*-*-hpux* sparc*-*-* } } } } } }
// For *-*-mingw* there is additionally one .def match
// { dg-final { scan-assembler-times "xyzzy" 3 { target *-*-mingw* } } }
// The IA64 and HPPA compilers generate external declarations in addition
diff --git a/gcc/testsuite/g++.dg/pr49718.C b/gcc/testsuite/g++.dg/pr49718.C
index b1cc5deb7ac..da443724fe1 100644
--- a/gcc/testsuite/g++.dg/pr49718.C
+++ b/gcc/testsuite/g++.dg/pr49718.C
@@ -2,7 +2,8 @@
/* { dg-options "-O2 -finstrument-functions" } */
/* { dg-additional-options "-mno-explicit-relocs" { target alpha*-*-* } } */
/* { dg-additional-options "-mno-relax-pic-calls" { target mips*-*-* } } */
-/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 1 { target { ! { hppa*-*-hpux* } } } } } */
+/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 1 { target { ! elf } && target { ! { hppa*-*-hpux* } } } } } */
+/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 2 { target { elf && { ! { hppa*-*-hpux* } } } } } } */
/* { dg-final { scan-assembler-times "__cyg_profile_func_enter,%r" 1 { target hppa*-*-hpux* } } } */
#define NOINSTR __attribute__((no_instrument_function))
diff --git a/gcc/testsuite/g++.dg/stackprotectexplicit2.C b/gcc/testsuite/g++.dg/stackprotectexplicit2.C
index 9cf9ab909c9..042305618e0 100644
--- a/gcc/testsuite/g++.dg/stackprotectexplicit2.C
+++ b/gcc/testsuite/g++.dg/stackprotectexplicit2.C
@@ -24,4 +24,5 @@ int __attribute__((stack_protect)) c()
}
-/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */ \ No newline at end of file
+/* { dg-final { scan-assembler-times "stack_chk_fail" 3 { target elf } } } */
+/* { dg-final { scan-assembler-times "stack_chk_fail" 2 { target { ! elf } } } } */
diff --git a/gcc/testsuite/gcc.dg/fstack-protector-strong.c b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
index 8e9d891acea..50ea5d0b112 100644
--- a/gcc/testsuite/gcc.dg/fstack-protector-strong.c
+++ b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
@@ -154,4 +154,5 @@ void foo12 ()
global3 ();
}
-/* { dg-final { scan-assembler-times "stack_chk_fail" 12 } } */
+/* { dg-final { scan-assembler-times "stack_chk_fail" 13 { target elf } } } */
+/* { dg-final { scan-assembler-times "stack_chk_fail" 12 { target { ! elf } } } } */
diff --git a/gcc/testsuite/gcc.dg/pr35514-1.c b/gcc/testsuite/gcc.dg/pr35514-1.c
new file mode 100644
index 00000000000..43eeec46d32
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr35514-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile { target { elf } } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler ".type\[^\\n\]*object, \(%|@\)object" } } */
+/* { dg-final { scan-assembler ".type\[^\\n\]*function, \(%|@\)function" } } */
+
+/* Verify that we generate proper symbol types for external reference. */
+
+extern int object;
+void function (void);
+
+int
+foo (void)
+{
+ function ();
+ return object;
+}
diff --git a/gcc/testsuite/gcc.dg/pr35514-2.c b/gcc/testsuite/gcc.dg/pr35514-2.c
new file mode 100644
index 00000000000..d915bf520a2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr35514-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { elf } } } */
+/* { dg-require-effective-target tls } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not ".type\[^\\n\]*object, \(%|@\)object" } } */
+
+/* Verify that we generate proper symbol types for external reference. */
+
+extern __thread int object;
+
+int
+foo (void)
+{
+ return object;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c
index 9d18dd7efdc..0903ea2e342 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c
@@ -46,7 +46,8 @@ int xxx(void)
/* CRIS keeps the address in a register. */
/* m68k sometimes puts the address in a register, depending on CPU and PIC. */
-/* { dg-final { scan-assembler-times "foo" 5 { xfail hppa*-*-* ia64*-*-* sh*-*-* cris-*-* crisv32-*-* fido-*-* m68k-*-* i?86-*-mingw* i?86-*-cygwin* x86_64-*-mingw* visium-*-* } } } */
+/* { dg-final { scan-assembler-times "foo" 5 { target { ! elf } xfail hppa*-*-* ia64*-*-* sh*-*-* cris-*-* crisv32-*-* fido-*-* m68k-*-* i?86-*-mingw* i?86-*-cygwin* x86_64-*-mingw* visium-*-* } } } */
+/* { dg-final { scan-assembler-times "foo" 6 { target elf xfail hppa*-*-* ia64*-*-* sh*-*-* cris-*-* crisv32-*-* fido-*-* m68k-*-* visium-*-* } } } */
/* { dg-final { scan-assembler-times "foo,%r" 5 { target hppa*-*-* } } } */
/* { dg-final { scan-assembler-times "= foo" 5 { target ia64*-*-* } } } */
/* { dg-final { scan-assembler-times "call\[ \t\]*_foo" 5 { target i?86-*-mingw* i?86-*-cygwin* } } } */
diff --git a/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c b/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c
index ddd1ef7c0b2..6553c12e593 100644
--- a/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c
+++ b/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=atom -mmemcpy-strategy=vector_loop:2000:align,libcall:-1:align" } */
-/* { dg-final { scan-assembler-times "memcpy" 2 } } */
+/* { dg-final { scan-assembler-times "memcpy" 3 { target elf } } } */
+/* { dg-final { scan-assembler-times "memcpy" 2 { target { ! elf } } } } */
char a[2048];
char b[2048];
diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-1.c b/gcc/testsuite/gcc.target/i386/memset-strategy-1.c
index d1b97c5df10..c249d1e6e88 100644
--- a/gcc/testsuite/gcc.target/i386/memset-strategy-1.c
+++ b/gcc/testsuite/gcc.target/i386/memset-strategy-1.c
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=atom -mmemset-strategy=libcall:-1:align" } */
-/* { dg-final { scan-assembler-times "memset" 2 } } */
+/* { dg-final { scan-assembler-times "memset" 3 { target elf } } } */
+/* { dg-final { scan-assembler-times "memset" 2 { target { ! elf } } } } */
char a[2048];
void t (void)
diff --git a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90 b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
index c8eb50d621f..19c608265f9 100644
--- a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
+++ b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
@@ -16,6 +16,7 @@ integer :: aa(4,4)
call test(aa)
end
-! { dg-final { scan-assembler-times "\[ \t\]\[$,_0-9\]*myBindC" 1 { target { ! { hppa*-*-* } } } } }
+! { dg-final { scan-assembler-times "\[ \t\]\[$,_0-9\]*myBindC" 1 { target { ! elf } && target { ! { hppa*-*-* } } } } }
+! { dg-final { scan-assembler-times "\[ \t\]\[$,_0-9\]*myBindC" 2 { target { elf && { ! { hppa*-*-* } } } } } }
! { dg-final { scan-assembler-times "myBindC,%r2" 1 { target { hppa*-*-* } } } }
! { dg-final { scan-tree-dump-times "test \\\(&parm\\." 1 "original" } }
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 4d5b0a3df61..53af66dd476 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6484,3 +6484,23 @@ proc check_effective_target_builtin_eh_return { } {
}
} "" ]
}
+
+# Returns 1 if the target is ELF.
+
+proc check_effective_target_elf { } {
+ global check_effective_target_elf_saved
+ global tool
+
+ if [info exists check_effective_target_elf_saved] {
+ verbose "check_effective_target_elf returning saved $check_effective_target_elf_saved" 2
+ } else {
+ set objformat [gcc_target_object_format]
+ if { $objformat == "elf" } {
+ set check_effective_target_elf_saved 1
+ } else {
+ set check_effective_target_elf_saved 0
+ }
+ verbose "check_effective_target_elf returning $check_effective_target_elf_saved" 2
+ }
+ return $check_effective_target_elf_saved
+}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index f1564bc4955..85f0a2375cc 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -7494,7 +7494,7 @@ elf_record_gcc_switches (print_switch_type type, const char * name)
}
/* Emit text to declare externally defined symbols. It is needed to
- properly support non-default visibility. */
+ properly support non-default visibility and specify symbol type. */
void
default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
tree decl,
@@ -7503,10 +7503,28 @@ default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
/* We output the name if and only if TREE_SYMBOL_REFERENCED is
set in order to avoid putting out names that are never really
used. Always output visibility specified in the source. */
- if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
- && (DECL_VISIBILITY_SPECIFIED (decl)
- || targetm.binds_local_p (decl)))
- maybe_assemble_visibility (decl);
+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+ {
+ if (DECL_VISIBILITY_SPECIFIED (decl)
+ || targetm.binds_local_p (decl))
+ maybe_assemble_visibility (decl);
+
+#ifdef ASM_OUTPUT_TYPE_DIRECTIVE
+ /* We don't output symbol type for reference to external TLS
+ symbol since assembler will generate TLS symbol type based
+ on TLS relocation and Solaris assembler only supports the
+ @tls_obj type directive, not the @tls_object type directive
+ used by GNU assmbler, which doesn't understand the @tls_obj
+ type directive. */
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
+ else if (TREE_CODE (decl) == VAR_DECL)
+ {
+ if (!DECL_THREAD_LOCAL_P (decl))
+ ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "object");
+ }
+#endif
+ }
}
/* The default hook for TARGET_ASM_OUTPUT_SOURCE_FILENAME. */