This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix .tls_common handling in ld -r
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 15 Jun 2006 15:04:02 +0200
- Subject: [PATCH] Fix .tls_common handling in ld -r
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
cat > a.c <<EOF
__asm (".tls_common foo,4,4");
int
main (void)
{
extern __thread int foo;
return foo;
}
EOF
gcc -c a.c
ld -r -o b.o a.o
gcc -o b b.o
used to segfault the linker (before BZ#2735 fix), now just issues
a bogus warning message:
Warning: alignment 4 of common symbol `foo' in b.o is greater than the alignment (1) of its section .tcommon
and e.g. doesn't create PT_TLS segment at all.
The problem is that ld -r creates a bogus section:
[ 7] .tcommon NOBITS 0000000000000000 000088 000000 00 WAT 0 0 1
The following patch fixes this and is the solution e.g. IA-64 uses for its
.scommon section as well.
Ok to commit?
2006-06-15 Jakub Jelinek <jakub@redhat.com>
* elflink.c (elf_link_add_object_symbols): Don't create .tcommon
section for relocatable link.
--- bfd/elflink.c.jj 2006-06-15 14:31:01.000000000 +0200
+++ bfd/elflink.c 2006-06-15 14:40:51.000000000 +0200
@@ -3621,7 +3621,8 @@ elf_link_add_object_symbols (bfd *abfd,
goto error_free_vers;
if (isym->st_shndx == SHN_COMMON
- && ELF_ST_TYPE (isym->st_info) == STT_TLS)
+ && ELF_ST_TYPE (isym->st_info) == STT_TLS
+ && !info->relocatable)
{
asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon");
Jakub