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: Clear non_elf on _GLOBAL_OFFSET_TABLE_


Hi,

This patch clears non_elf on _GLOBAL_OFFSET_TABLE_ and keeps .got.plt
section if _GLOBAL_OFFSET_TABLE_ is referenced.  OK to install?

Thanks.


H.J.
---
bfd/

2010-09-23  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11812
	* elf32-i386.c (elf_i386_size_dynamic_sections): Don't
	 allocate .got.plt section if there are no GOT nor PLT
	 entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.
	 * elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Li.kewise.

	* elflink.c (_bfd_elf_create_got_section): Clear non_elf on
	_GLOBAL_OFFSET_TABLE_.

ld/testsuite/

2010-09-23  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11812
	* ld-i386/nogot1.s: Don't use GOTOFF.

diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7a426d5..8d8bc85 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2559,10 +2559,17 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   if (htab->elf.sgotplt)
     {
+      struct elf_link_hash_entry *got;
+      got = elf_link_hash_lookup (elf_hash_table (info),
+				  "_GLOBAL_OFFSET_TABLE_",
+				  FALSE, FALSE, FALSE);
+
       /* Don't allocate .got.plt section if there are no GOT nor PLT
-         entries.  */
-      if ((htab->elf.sgotplt->size
-	   == get_elf_backend_data (output_bfd)->got_header_size)
+         entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.  */
+      if ((got == NULL
+	   || !got->ref_regular_nonweak)
+	  && (htab->elf.sgotplt->size
+	      == get_elf_backend_data (output_bfd)->got_header_size)
 	  && (htab->elf.splt == NULL
 	      || htab->elf.splt->size == 0)
 	  && (htab->elf.sgot == NULL
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 9da73a1..677d9c4 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2378,10 +2378,17 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   if (htab->elf.sgotplt)
     {
+      struct elf_link_hash_entry *got;
+      got = elf_link_hash_lookup (elf_hash_table (info),
+				  "_GLOBAL_OFFSET_TABLE_",
+				  FALSE, FALSE, FALSE);
+
       /* Don't allocate .got.plt section if there are no GOT nor PLT
-         entries.  */
-      if ((htab->elf.sgotplt->size
-	   == get_elf_backend_data (output_bfd)->got_header_size)
+         entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.  */
+      if ((got == NULL
+	   || !got->ref_regular_nonweak)
+	  && (htab->elf.sgotplt->size
+	      == get_elf_backend_data (output_bfd)->got_header_size)
 	  && (htab->elf.splt == NULL
 	      || htab->elf.splt->size == 0)
 	  && (htab->elf.sgot == NULL
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 4351e28..db23f6e 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -150,6 +150,7 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
       elf_hash_table (info)->hgot = h;
       if (h == NULL)
 	return FALSE;
+      h->non_elf = 0;
     }
 
   return TRUE;
diff --git a/ld/testsuite/ld-i386/nogot1.s b/ld/testsuite/ld-i386/nogot1.s
index c657231..016e172 100644
--- a/ld/testsuite/ld-i386/nogot1.s
+++ b/ld/testsuite/ld-i386/nogot1.s
@@ -5,6 +5,6 @@ bar:
 .globl foo
 	.type	foo, @function
 foo:
-	leal	bar@GOTOFF(%ecx), %eax
+	leal	bar, %eax
 	ret
 	.size	foo, .-foo


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