This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR ld/5913: IA64 linker crashes on supported relocations


Hi,
IA64 Linker crashes on bad input in
http://www.sourceware.org/bugzilla/show_bug.cgi?id=5913
[hjl@gnu-11 776]$ ld -shared test.o
ld: BFD (Linux/GNU Binutils) 2.18.50.0.5.20080303 assertion fail
elf64-ia64.c:4205
Segmentation fault
This patch will give
./ld -shared -o test.so test.o
./ld: test.o: unsupported relocation DTPREL64LSB against `val' at 0xea
in section `.debug_info'.
./ld: final link failed: Nonrepresentable section on output
OK to install?
Thanks.
H.J.
2008年03月11日 H.J. Lu <hongjiu.lu@intel.com>
	PR ld/5913
	* elfxx-ia64.c (elfNN_ia64_tprel_base): Remove BFD_ASSERT.
	(elfNN_ia64_dtprel_base): Likewise.
	(elfNN_ia64_relocate_section): Go to unsupported_tls_reloc if
	tls_sec is NULL before calling elfNN_ia64_tprel_base or
	elfNN_ia64_dtprel_base. Report unsupported TLS relocations.
--- bfd/elfxx-ia64.c.check	2008年03月11日 12:17:17.000000000 -0700
+++ bfd/elfxx-ia64.c	2008年03月11日 13:01:14.000000000 -0700
@@ -4189,8 +4189,6 @@ static bfd_vma
 elfNN_ia64_tprel_base (struct bfd_link_info *info)
 {
 asection *tls_sec = elf_hash_table (info)->tls_sec;
-
- BFD_ASSERT (tls_sec != NULL);
 return tls_sec->vma - align_power ((bfd_vma) ARCH_SIZE / 4,
 				 tls_sec->alignment_power);
 }
@@ -4202,7 +4200,6 @@ elfNN_ia64_tprel_base (struct bfd_link_i
 static bfd_vma
 elfNN_ia64_dtprel_base (struct bfd_link_info *info)
 {
- BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
 return elf_hash_table (info)->tls_sec->vma;
 }
 
@@ -4972,6 +4969,8 @@ elfNN_ia64_relocate_section (bfd *output
 	case R_IA64_TPREL14:
 	case R_IA64_TPREL22:
 	case R_IA64_TPREL64I:
+	 if (elf_hash_table (info)->tls_sec == NULL)
+	 goto unsupported_tls_reloc;
 	 value -= elfNN_ia64_tprel_base (info);
 	 r = elfNN_ia64_install_value (hit_addr, value, r_type);
 	 break;
@@ -4983,6 +4982,8 @@ elfNN_ia64_relocate_section (bfd *output
 	case R_IA64_DTPREL32MSB:
 	case R_IA64_DTPREL64LSB:
 	case R_IA64_DTPREL64MSB:
+	 if (elf_hash_table (info)->tls_sec == NULL)
+	 goto unsupported_tls_reloc;
 	 value -= elfNN_ia64_dtprel_base (info);
 	 r = elfNN_ia64_install_value (hit_addr, value, r_type);
 	 break;
@@ -5002,9 +5003,15 @@ elfNN_ia64_relocate_section (bfd *output
 		if (!dynamic_symbol_p)
 		 {
 		 if (!info->shared)
-		 value -= elfNN_ia64_tprel_base (info);
+		 {
+			if (elf_hash_table (info)->tls_sec == NULL)
+			 goto unsupported_tls_reloc;
+			value -= elfNN_ia64_tprel_base (info);
+		 }
 		 else
 		 {
+			if (elf_hash_table (info)->tls_sec == NULL)
+			 goto unsupported_tls_reloc;
 			r_addend += value - elfNN_ia64_dtprel_base (info);
 			dynindx = 0;
 		 }
@@ -5018,7 +5025,11 @@ elfNN_ia64_relocate_section (bfd *output
 		break;
 	 case R_IA64_LTOFF_DTPREL22:
 		if (!dynamic_symbol_p)
-		 value -= elfNN_ia64_dtprel_base (info);
+		 {
+		 if (elf_hash_table (info)->tls_sec == NULL)
+		 goto unsupported_tls_reloc;
+		 value -= elfNN_ia64_dtprel_base (info);
+		 }
 		got_r_type = R_IA64_DTPRELNNLSB;
 		break;
 	 }
@@ -5069,6 +5080,7 @@ elfNN_ia64_relocate_section (bfd *output
 	case bfd_reloc_outofrange:
 	case bfd_reloc_overflow:
 	default:
+unsupported_tls_reloc:
 	 {
 	 const char *name;
 
@@ -5080,6 +5092,25 @@ elfNN_ia64_relocate_section (bfd *output
 
 	 switch (r_type)
 	 {
+	 case R_IA64_TPREL14:
+	 case R_IA64_TPREL22:
+	 case R_IA64_TPREL64I:
+	 case R_IA64_DTPREL14:
+	 case R_IA64_DTPREL22:
+	 case R_IA64_DTPREL64I:
+	 case R_IA64_DTPREL32LSB:
+	 case R_IA64_DTPREL32MSB:
+	 case R_IA64_DTPREL64LSB:
+	 case R_IA64_DTPREL64MSB:
+	 case R_IA64_LTOFF_TPREL22:
+	 case R_IA64_LTOFF_DTPMOD22:
+	 case R_IA64_LTOFF_DTPREL22:
+		(*_bfd_error_handler)
+		 (_("%B: unsupported relocation %s against `%s' at 0x%lx in section `%A'."),
+		 input_bfd, input_section, howto->name, name,
+		 rel->r_offset);
+		break;
+
 	 case R_IA64_PCREL21B:
 	 case R_IA64_PCREL21BI:
 	 case R_IA64_PCREL21M:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

AltStyle によって変換されたページ (->オリジナル) /