[PATCH] Avoid R_IA64_NONE relocations when relaxing

H. J. Lu hjl@lucon.org
Wed Aug 3 18:12:00 GMT 2005


On Tue, Aug 02, 2005 at 05:25:19PM +0200, Andreas Schwab wrote:
> Nearly half of the dynamic relocation in libc.so.6.1 are R_IA64_NONE
> relocation.  With this patch all of them are elided.  Tested on ia64-linux
> and sucessfully built and tested glibc with it.
> 
> Andreas.
> 
> 2005-08-02  Andreas Schwab  <schwab@suse.de>
> 
> 	* elfxx-ia64.c (struct elfNN_ia64_allocate_data): Add only_got.
> 	(elfNN_ia64_relax_section): Reallocate .rela.got when .got has
> 	changed.
> 	(allocate_dynrel_entries): Only look at GOT relocations when
> 	only_got is true.
> 	(elfNN_ia64_size_dynamic_sections): Set only_got to false before
> 	calling allocate_dynrel_entries.
> 
> --- bfd/elfxx-ia64.c.~1.169.~	2005-07-11 10:07:03.000000000 +0200
> +++ bfd/elfxx-ia64.c	2005-08-02 15:53:14.000000000 +0200
> @@ -172,6 +172,7 @@ struct elfNN_ia64_allocate_data
>  {
>    struct bfd_link_info *info;
>    bfd_size_type ofs;
> +  bfd_boolean only_got;
>  };
>  
>  #define elfNN_ia64_hash_table(p) \
> @@ -1337,7 +1338,17 @@ elfNN_ia64_relax_section (abfd, sec, lin
>        elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data);
>        ia64_info->got_sec->size = data.ofs;
>  
> -      /* ??? Resize .rela.got too.  */
> +      if (ia64_info->root.dynamic_sections_created)
> +	{
> +	  /* Resize .rela.got.  */
> +	  ia64_info->rel_got_sec->size = 0;

ia64_info->rel_got_sec can be NULL if its size is 0. It happens on
RHEL 3 during "make check":

FAIL: vers3
FAIL: vers4
FAIL: vers6
FAIL: vers15
FAIL: vers16
FAIL: vers19
FAIL: vers23d
FAIL: vers23
FAIL: ELF weak func first
FAIL: ELF weak func last
FAIL: ELF weak data first
FAIL: ELF weak data last
FAIL: ELF weak data first common
FAIL: ELF weak data last common


This patch seems to work for me.


H.J.
----
2005-08-03  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_relax_section): Resize .rela.got
	only if it isn't NULL.

--- bfd/elfxx-ia64.c.got	2005-08-03 10:12:58.910396487 -0700
+++ bfd/elfxx-ia64.c	2005-08-03 11:01:42.578498798 -0700
@@ -1338,7 +1338,8 @@ elfNN_ia64_relax_section (abfd, sec, lin
       elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data);
       ia64_info->got_sec->size = data.ofs;
 
-      if (ia64_info->root.dynamic_sections_created)
+      if (ia64_info->root.dynamic_sections_created
+	  && ia64_info->rel_got_sec != NULL)
 	{
 	  /* Resize .rela.got.  */
 	  ia64_info->rel_got_sec->size = 0;



More information about the Binutils mailing list