public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] .plt32768+ sparc64 fixes, sizeof_hash_entry fix
@ 1999-07-26  9:24 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 1999-07-26  9:24 UTC (permalink / raw)
  To: binutils; +Cc: Richard Henderson, David S. Miller

Hi!

This patch fixes linkage of .plt32768+ entries and changes .hash section
entry size from 8 to 4 as that's what ABI requires and Solaris uses (like
mips64). This latter change breaks sparc64 binary compatibility with shared
libraries, but I wonder how many people beside me run sparc64 shared
userland anyway.

1999-07-25  Jakub Jelinek  <jj@ultra.linux.cz>

	* bfd/elf64-sparc.c (sparc64_elf_build_plt): Cosmetic change - ABI
	wants ba,a,pt %xcc instead of %icc.
	Emit correct .PLT0-(.PLTN+4) initial value into the pointer slots
	of large PLT entries.
	(sparc64_elf_plt_ptr_offset): Fix calculation.
	(sparc64_elf_finish_dynamic_symbol): Negative value of R_SPARC_JMP_SLOT
	addend should be relative to load address, not .plt section start.
	(sparc64_elf_size_info): Sparc64 uses 32bit .hash entries.

--- bfd/elf64-sparc.c.jj	Fri Jul 23 16:46:12 1999
+++ bfd/elf64-sparc.c	Sat Jul 24 15:31:17 1999
@@ -820,8 +820,8 @@ sparc64_elf_build_plt (output_bfd, conte
       /* sethi (. - plt0), %g1 */
       sethi = 0x03000000 | (i * PLT_ENTRY_SIZE);
 
-      /* ba,a,pt %icc, plt1 */
-      ba = 0x30480000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff);
+      /* ba,a,pt %xcc, plt1 */
+      ba = 0x30680000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff);
 
       bfd_put_32 (output_bfd, sethi, entry);
       bfd_put_32 (output_bfd, ba, entry+4);
@@ -858,7 +858,7 @@ sparc64_elf_build_plt (output_bfd, conte
 	  bfd_put_32 (output_bfd, 0x83c3c001, entry+16); /* jmpl %o7+%g1,%g1 */
 	  bfd_put_32 (output_bfd, 0x9e100005, entry+20); /* mov %g5,%o7 */
 
-	  bfd_put_64 (output_bfd, contents - entry+4, ptr);
+	  bfd_put_64 (output_bfd, contents - (entry+4), ptr);
 	}
     }
 }
@@ -893,11 +893,15 @@ sparc64_elf_plt_ptr_offset (index, max)
 
   /* See above for details.  */
 
-  block = (index - LARGE_PLT_THRESHOLD) / 160;
-  ofs = (index - LARGE_PLT_THRESHOLD) % 160;
-  last = (max - LARGE_PLT_THRESHOLD) % 160;
+  block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160)
+	  + LARGE_PLT_THRESHOLD;
+  ofs = index - block;
+  if (block + 160 > max)
+    last = (max - LARGE_PLT_THRESHOLD) % 160;
+  else
+    last = 160;
 
-  return ((LARGE_PLT_THRESHOLD + block*160) * PLT_ENTRY_SIZE
+  return (block * PLT_ENTRY_SIZE
 	  + last * 6*4
 	  + ofs * 8);
 }
@@ -2244,7 +2248,8 @@ sparc64_elf_finish_dynamic_symbol (outpu
 	{
 	  int max = splt->_raw_size / PLT_ENTRY_SIZE;
 	  rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max);
-	  rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4);
+	  rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4)
+			  -(splt->output_section->vma + splt->output_offset);
 	}
       rela.r_offset += (splt->output_section->vma + splt->output_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
@@ -2535,7 +2540,7 @@ const struct elf_size_info sparc64_elf_s
   sizeof (Elf64_External_Sym),
   sizeof (Elf64_External_Dyn),
   sizeof (Elf_External_Note),
-  8,		/* hash-table entry size */
+  4,		/* hash-table entry size */
   /* internal relocations per external relocations.
      For link purposes we use just 1 internal per
      1 external, for assembly and slurp symbol table

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux  |  http://ultra.linux.cz/  |  http://ultra.penguin.cz/
Linux version 2.2.10 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-07-26  9:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-26  9:24 [PATCH] .plt32768+ sparc64 fixes, sizeof_hash_entry fix Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).