aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-02-12 16:44:36 +1030
committerAlan Modra <amodra@gmail.com>2014-02-12 22:10:09 +1030
commit795bc6b3eac9e3f80279df69c05d70fc44eaaa4c (patch)
tree05936288596641f8b197892fe10826ead1935987 /bfd/elf32-ppc.c
parentb407645f7ef086a9a527c8f62499b4255868e748 (diff)
downloadgdb-795bc6b3eac9e3f80279df69c05d70fc44eaaa4c.zip
gdb-795bc6b3eac9e3f80279df69c05d70fc44eaaa4c.tar.gz
gdb-795bc6b3eac9e3f80279df69c05d70fc44eaaa4c.tar.bz2
Enable ppc476 workaround for ld -r.
The Linux kernel builds modules using ld -r. These might need the ppc476 workaround, so enable it for ld -r if sections have sufficient alignment to tell location within a page. bfd/ * elf32-ppc.c (ppc_elf_relax_section): Enable ppc476 workaround for ld -r, when code sections are sufficiently aligned. * elf32-ppc.h (struct ppc_elf_params): Delete pagesize. Add pagesize_p2. ld/ * emultempl/ppc32elf.em (pagesize): New static var. (ppc_after_open_output): Set params.pagesize_p2 from pagesize. (PARSE_AND_LIST_ARGS_CASES): Adjust to use pagesize.
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r--bfd/elf32-ppc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 0b43b9b..f7c0366 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -6690,7 +6690,7 @@ ppc_elf_relax_section (bfd *abfd,
do anything. The linker doesn't support mixing -shared and -r
anyway. */
if (link_info->relocatable && link_info->shared)
- return TRUE;
+ return TRUE;
htab = ppc_elf_hash_table (link_info);
if (htab == NULL)
@@ -7060,16 +7060,18 @@ ppc_elf_relax_section (bfd *abfd,
workaround_change = FALSE;
newsize = trampoff;
- if (htab->params->ppc476_workaround)
+ if (htab->params->ppc476_workaround
+ && (!link_info->relocatable
+ || isec->output_section->alignment_power >= htab->params->pagesize_p2))
{
bfd_vma addr, end_addr;
unsigned int crossings;
- unsigned int pagesize = htab->params->pagesize;
+ bfd_vma pagesize = (bfd_vma) 1 << htab->params->pagesize_p2;
addr = isec->output_section->vma + isec->output_offset;
end_addr = addr + trampoff - 1;
addr &= -pagesize;
- crossings = ((end_addr & -pagesize) - addr) / pagesize;
+ crossings = ((end_addr & -pagesize) - addr) >> htab->params->pagesize_p2;
if (crossings != 0)
{
/* Keep space aligned, to ensure the patch code itself does
@@ -9134,11 +9136,14 @@ ppc_elf_relocate_section (bfd *output_bfd,
}
if (htab->params->ppc476_workaround
- && input_section->sec_info_type == SEC_INFO_TYPE_TARGET)
+ && input_section->sec_info_type == SEC_INFO_TYPE_TARGET
+ && (!info->relocatable
+ || (input_section->output_section->alignment_power
+ >= htab->params->pagesize_p2)))
{
struct ppc_elf_relax_info *relax_info;
bfd_vma start_addr, end_addr, addr;
- unsigned int pagesize = htab->params->pagesize;
+ bfd_vma pagesize = (bfd_vma) 1 << htab->params->pagesize_p2;
relax_info = elf_section_data (input_section)->sec_info;
if (relax_info->workaround_size != 0)