[PATCH] MIPS/BFD: Fix n64 GOT header size in the ELF backend
Maciej W. Rozycki
Mon May 7 09:56:00 GMT 2012
I've noticed the MIPS backend does not set the size of the GOT header
correctly in the ELF backend structure for the n64 ABI. This is mostly
harmless because the MIPS backend does not use the value from the
structure and hardcoded the header size to twice the GOT entry size.
Furthermore the MIPS backend does not use the generic GOT creation
function (_bfd_elf_create_got_section) so it escapes damage there too.
However the size from the ELF backend structure is still used in linker
garbage collection (bfd_elf_gc_common_finalize_got_offsets) that the MIPS
backend does use, although GC is not on by default. Therefore I propose
to fix it as below and make the MIPS backend use the GOT header size from
the ELF backend structure too so that there is a central place everything
depends on and any breakage is easily noticed. Surprisingly enough this
is also a bit cheaper as MIPS_ELF_GOT_SIZE implies an extra pointer
dereference and calculation (the multiplication by 2 should be cancelled
by any sane compiler though).
I have no test case available and I don't remember anymore how I spotted
this, most probably noticed it by inspection while debugging the n64
compound relocation breakage with GC I have fixed recently. However I
believe the change is obvious enough and it does not cause any regressions
in mips64-gnu-linux testing. OK to apply?
2012-05-07 Maciej W. Rozycki <firstname.lastname@example.org>
* elf64-mips.c (elf_backend_got_header_size): Correct definition.
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Use the ELF
backend's GOT header size instead of hardcoding it.
@@ -3261,7 +3261,7 @@ const struct elf_size_info mips_elf64_si
#define elf_backend_grok_prstatus elf64_mips_grok_prstatus
#define elf_backend_grok_psinfo elf64_mips_grok_psinfo
-#define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
+#define elf_backend_got_header_size (8 * MIPS_RESERVED_GOTNO)
/* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
work better/work only in RELA, so we default to this. */
@@ -8293,7 +8293,8 @@ _bfd_mips_elf_adjust_dynamic_symbol (str
/* On non-VxWorks targets, the first two entries in .got.plt
are reserved. */
- htab->sgotplt->size += 2 * MIPS_ELF_GOT_SIZE (dynobj);
+ += get_elf_backend_data (dynobj)->got_header_size;
/* On VxWorks, also allocate room for the header's
.rela.plt.unloaded entries. */
More information about the Binutils