This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Switch to .bss from .tdata on Solaris 2 (PR target/38118)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 05 Jan 2011 18:12:21 +0100
- Subject: Switch to .bss from .tdata on Solaris 2 (PR target/38118)
There is a single remaining objc failure on Solaris 2/x86 (both 32 and
64-bit), which only occurs if using Sun as instead of gas:
FAIL: objc.dg/torture/tls/thr-init-3.m -O2 -fwhopr (test for excess errors)
WARNING: objc.dg/torture/tls/thr-init-3.m -O2 -fwhopr compilation failed to p
roduce executable
Excess errors:
ld: warning: symbol '_OBJC_CLASS_NAME_3.2113.2105' has invalid section index; ignored:
(file /var/tmp//ccqjayQH.ltrans0.ltrans.o value=COMMON);
ld: fatal: relocation error: R_386_32: file /var/tmp//ccqjayQH.ltrans0.ltrans.o: section [12].rel.data: attempt to relocate with respect to unknown symbol _OBJC_CLASS_NAME_3.2113.2105: offset 0x10, symbol index 13
This turned out to be another instance of PR target/38118: with as, the
symbol is created as
[14] | 0| 1|TLS |LOCL |0 |COMMON |_OBJC_CLASS_NAME_3.2072.2064
while with gas, one gets
[16] | 0| 1|OBJT |LOCL |0 |5 |_OBJC_CLASS_NAME_3.2072.2064
A similar bug has been fixed ages ago:
2004-06-14 Jakub Jelinek <jakub@redhat.com>
PR target/15178
* config/i386/sol2.h (ASM_OUTPUT_DEF_FROM_DECLS): Define.
but that only handled coming from .tbss, while here the previous section
is .tdata:
.section .tdata,"awt",@progbits
.align 4
.type as.2329.2082.2079, @tls_obj
.size as.2329.2082.2079, 4
as.2329.2082.2079:
.long 3
.local _OBJC_CLASS_NAME_3.2072.2064
.comm _OBJC_CLASS_NAME_3.2072.2064,1,1
.tbss is marked SECTION_TLS | SECTION_BSS, while .tdata is SECTION_TLS
only. The patch below handles this new case, fixes the issue and was
bootstrapped without regressions on i386-pc-solaris2.11.
I'll commit it to mainline as soon as a sparc-sun-solaris2.11 bootstrap
has completed; right now, I have no intention of backporting it to the
4.4 and 4.5 branches unless there's a need.
Rainer
2010-12-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/38118
* config/sol2.h (ASM_OUTPUT_ALIGNED_COMMON): Also switch to .bss
if coming from .tdata.
* config/i386/sol2-10.h (ASM_OUTPUT_ALIGNED_COMMON): Likewise.
diff -r b2a32256838e gcc/config/i386/sol2-10.h
--- a/gcc/config/i386/sol2-10.h Tue Dec 28 20:30:06 2010 +0100
+++ b/gcc/config/i386/sol2-10.h Thu Dec 30 12:56:36 2010 +0100
@@ -58,8 +58,7 @@
{ \
if (TARGET_SUN_TLS \
&& in_section \
- && ((in_section->common.flags & (SECTION_TLS | SECTION_BSS)) \
- == (SECTION_TLS | SECTION_BSS))) \
+ && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
switch_to_section (bss_section); \
x86_elf_aligned_common (FILE, NAME, SIZE, ALIGN); \
} \
diff -r b2a32256838e gcc/config/sol2.h
--- a/gcc/config/sol2.h Tue Dec 28 20:30:06 2010 +0100
+++ b/gcc/config/sol2.h Thu Dec 30 12:56:36 2010 +0100
@@ -279,7 +279,7 @@
} \
while (0)
-/* Solaris 'as' has a bug: a .common directive in .tbss section
+/* Solaris 'as' has a bug: a .common directive in .tbss or .tdata section
behaves as .tls_common rather than normal non-TLS .common. */
#undef ASM_OUTPUT_ALIGNED_COMMON
#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
@@ -287,8 +287,7 @@
{ \
if (TARGET_SUN_TLS \
&& in_section \
- && ((in_section->common.flags & (SECTION_TLS | SECTION_BSS)) \
- == (SECTION_TLS | SECTION_BSS))) \
+ && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
switch_to_section (bss_section); \
fprintf ((FILE), "%s", COMMON_ASM_OP); \
assemble_name ((FILE), (NAME)); \
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University