This is the mail archive of the binutils@sources.redhat.com 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] Fix elf32-ppc.c with >= 8192 .plt entries


Hi!

Libraries with >= 8192 .plt entries are broken in multiple ways
apparently. The size of .plt section is wrong, plt entry 8192
and following point into the middle of the large .plt slots
(ie. b instead of lis in each:
        lis %r11, %hi(index*4 + &plt[PLT_DATA_START_WORDS])
        lwzu %r12, %r11, %lo(index*4 + &plt[PLT_DATA_START_WORDS])
        b  &plt[PLT_TRAMPOLINE_ENTRY_WORDS]
        bctr
) and furthermore there is one R_PPC_NONE at index 8192 in .rela.plt
section and the last R_PPC_JMP_SLOT relocation is missing.
All this is because of the wrongly computed section size from which
everything else is derived.
When allocate_dynrelocs proccesses 8192th entry (ie. index 8191)
the hunk below increases _raw_size to
PLT_INITIAL_ENTRY_SIZE + PLT_NUM_SINGLE_ENTIES * PLT_ENTRY_SIZE and
thus the condition is true and plt entry with index 8191 occupies
2 slots, not just one. But of course entry with index 8192 should
start at 65608 and only index 8193 start should go up by 16 to 65624.
With this patch I was able to run prelink's reloc4 test, unprelinked
with lazy binding, unprelinked with LD_BIND_NOW=1 and prelinked.
Ok to commit?

2003-05-31  Jakub Jelinek  <jakub@redhat.com>

	* elf32-ppc.c (allocate_dynrelocs): Use single slot for first 8192
	plt entries, not just 8191.

--- bfd/elf32-ppc.c.jj	2003-05-30 11:19:17.000000000 -0400
+++ bfd/elf32-ppc.c	2003-05-30 18:22:31.000000000 -0400
@@ -2719,7 +2719,7 @@ allocate_dynrelocs (h, inf)
 	     for two entries is allocated.  */
 	  s->_raw_size += PLT_ENTRY_SIZE;
 	  if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE
-	      >= PLT_NUM_SINGLE_ENTRIES)
+	      > PLT_NUM_SINGLE_ENTRIES)
 	    s->_raw_size += PLT_ENTRY_SIZE;
 
 	  /* We also need to make an entry in the .rela.plt section.  */

	Jakub


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