This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Don't crash if tls_segment is NULL
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: rth at redhat dot com, roland at redhat dot com
- Date: Wed, 11 Sep 2002 12:54:53 +0200
- Subject: [PATCH] Don't crash if tls_segment is NULL
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
ld would crash if current library/binary has no PT_TLS segment but has
some @TPOFF/@NTPOFF/@DTPOFF relocs. This can happen in error cases only,
but nevertheless, ld shouldn't crash.
The last hunk is a fix to make ld actually fail if it prints
unresolvable relocation against symbol `foo' error message, ATM it would
pretend to succeed.
Ok to commit?
2002-09-11 Jakub Jelinek <jakub@redhat.com>
* elf32-i386.c (dtpoff_base, tpoff): Don't crash if tls_segment is
NULL.
(elf_i386_relocate_section): Return false after printing error about
unresolvable relocation.
--- bfd/elf32-i386.c.jj 2002-09-10 14:50:42.000000000 +0200
+++ bfd/elf32-i386.c 2002-09-11 12:45:43.000000000 +0200
@@ -1962,7 +1962,9 @@ static bfd_vma
dtpoff_base (info)
struct bfd_link_info *info;
{
- BFD_ASSERT (elf_hash_table (info)->tls_segment != NULL);
+ /* If tls_segment is NULL, we should have signalled an error already. */
+ if (elf_hash_table (info)->tls_segment == NULL)
+ return 0;
return elf_hash_table (info)->tls_segment->start;
}
@@ -1977,7 +1979,9 @@ tpoff (info, address)
struct elf_link_tls_segment *tls_segment
= elf_hash_table (info)->tls_segment;
- BFD_ASSERT (tls_segment != NULL);
+ /* If tls_segment is NULL, we should have signalled an error already. */
+ if (tls_segment == NULL)
+ return 0;
return (align_power (tls_segment->size, tls_segment->align)
+ tls_segment->start - address);
}
@@ -2756,12 +2760,15 @@ elf_i386_relocate_section (output_bfd, i
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
- (*_bfd_error_handler)
- (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
- bfd_archive_filename (input_bfd),
- bfd_get_section_name (input_bfd, input_section),
- (long) rel->r_offset,
- h->root.root.string);
+ {
+ (*_bfd_error_handler)
+ (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
+ bfd_archive_filename (input_bfd),
+ bfd_get_section_name (input_bfd, input_section),
+ (long) rel->r_offset,
+ h->root.root.string);
+ return false;
+ }
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
contents, rel->r_offset,
Jakub