This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ppc64 large toc tweaks
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 29 Jul 2010 17:19:37 +0930
- Subject: ppc64 large toc tweaks
Some tweaks related to large toc code optimisation.
bfd/
* elf64-ppc.c (ppc64_elf_edit_toc): Always adjust local syms in
.toc section, even when none are used in relocs.
gas/
* config/tc-ppc.c (ppc_fix_adjustable): Add got reloc types used
in large toc code.
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.332
diff -u -p -r1.332 elf64-ppc.c
--- bfd/elf64-ppc.c 1 Jul 2010 09:48:26 -0000 1.332
+++ bfd/elf64-ppc.c 29 Jul 2010 07:25:40 -0000
@@ -8248,6 +8248,7 @@ ppc64_elf_edit_toc (struct bfd_link_info
{
bfd_byte *contents, *src;
unsigned long off;
+ Elf_Internal_Sym *sym;
bfd_boolean local_toc_syms = FALSE;
/* Shuffle the toc contents, and at the same time convert the
@@ -8292,7 +8293,6 @@ ppc64_elf_edit_toc (struct bfd_link_info
unsigned long r_symndx;
asection *sym_sec;
struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
bfd_vma val;
r_type = ELF64_R_TYPE (rel->r_info);
@@ -8371,38 +8371,34 @@ ppc64_elf_edit_toc (struct bfd_link_info
/* We shouldn't have local or global symbols defined in the TOC,
but handle them anyway. */
- if (local_toc_syms)
- {
- Elf_Internal_Sym *sym;
-
- for (sym = local_syms;
- sym < local_syms + symtab_hdr->sh_info;
- ++sym)
- if (sym->st_value != 0
- && bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc)
- {
- unsigned long i;
-
- if (sym->st_value > toc->rawsize)
- i = toc->rawsize >> 3;
- else
- i = sym->st_value >> 3;
+ for (sym = local_syms;
+ sym < local_syms + symtab_hdr->sh_info;
+ ++sym)
+ if (sym->st_value != 0
+ && bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc)
+ {
+ unsigned long i;
- if ((skip[i] & (ref_from_discarded | can_optimize)) != 0)
- {
- (*_bfd_error_handler)
- (_("%s defined on removed toc entry"),
- bfd_elf_sym_name (ibfd, symtab_hdr, sym, NULL));
- do
- ++i;
- while ((skip[i] & (ref_from_discarded | can_optimize)));
- sym->st_value = (bfd_vma) i << 3;
- }
+ if (sym->st_value > toc->rawsize)
+ i = toc->rawsize >> 3;
+ else
+ i = sym->st_value >> 3;
- sym->st_value -= skip[i];
- symtab_hdr->contents = (unsigned char *) local_syms;
+ if ((skip[i] & (ref_from_discarded | can_optimize)) != 0)
+ {
+ if (local_toc_syms)
+ (*_bfd_error_handler)
+ (_("%s defined on removed toc entry"),
+ bfd_elf_sym_name (ibfd, symtab_hdr, sym, NULL));
+ do
+ ++i;
+ while ((skip[i] & (ref_from_discarded | can_optimize)));
+ sym->st_value = (bfd_vma) i << 3;
}
- }
+
+ sym->st_value -= skip[i];
+ symtab_hdr->contents = (unsigned char *) local_syms;
+ }
/* Adjust any global syms defined in this toc input section. */
if (toc_inf.global_toc_syms)
Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.173
diff -u -p -r1.173 tc-ppc.c
--- gas/config/tc-ppc.c 28 Jul 2010 05:21:38 -0000 1.173
+++ gas/config/tc-ppc.c 29 Jul 2010 07:25:43 -0000
@@ -5724,6 +5724,8 @@ ppc_fix_adjustable (fixS *fix)
&& fix->fx_r_type != BFD_RELOC_LO16_GOTOFF
&& fix->fx_r_type != BFD_RELOC_HI16_GOTOFF
&& fix->fx_r_type != BFD_RELOC_HI16_S_GOTOFF
+ && fix->fx_r_type != BFD_RELOC_PPC64_GOT16_DS
+ && fix->fx_r_type != BFD_RELOC_PPC64_GOT16_LO_DS
&& fix->fx_r_type != BFD_RELOC_GPREL16
&& fix->fx_r_type != BFD_RELOC_VTABLE_INHERIT
&& fix->fx_r_type != BFD_RELOC_VTABLE_ENTRY
--
Alan Modra
Australia Development Lab, IBM