PATCH: Change ia64 br relaxation failure message
H. J. Lu
hjl@lucon.org
Fri Feb 11 23:48:00 GMT 2005
On Thu, Feb 10, 2005 at 04:05:11PM -0800, H. J. Lu wrote:
> R_IA64_PCREL21B, R_IA64_PCREL21BI, R_IA64_PCREL21M and R_IA64_PCREL21F
> can fail if the input section is too big. Users get
>
> foo.o(.text+0x1000072): In function `main':
> foo.c: relocation truncated to fit: PCREL21B against symbol `foo'
> defined in .text section in foo.o
> /usr/local/bin/ld: final link failed: Nonrepresentable section on
> output
>
> and they may think it is a linker error. This patch changes it to
>
> ./ld: foo.o: Can't relax br (PCREL21B) in section `.text' with size
> 0x10000b0 (> 0x1000000).
> ./ld: final link failed: Nonrepresentable section on output
> collect2: ld returned 1 exit status
>
Hi Jim,
I just noticed a relaxation bug. We won't relax
foo:
huge text
br foo
since branch and target are in the same section. We can relax backward
branch in this case. Also we do &h->root without checking if h is NULL.
The updated patch fixes both problems.
H.J.
----
2005-02-10 H.J. Lu <hongjiu.lu@intel.com>
* elfxx-ia64.c (elfNN_ia64_relax_section): Allow relax
backward branch in the same section.
(elfNN_ia64_relocate_section): Inform users that the input
section is too big to relax br instruction when overflow
happens to R_IA64_PCREL21B, R_IA64_PCREL21BI, R_IA64_PCREL21M
and R_IA64_PCREL21F. Check h before accessing &h->root.
--- bfd/elfxx-ia64.c.big 2005-02-11 11:16:33.000000000 -0800
+++ bfd/elfxx-ia64.c 2005-02-11 12:12:58.353313904 -0800
@@ -994,9 +994,10 @@ elfNN_ia64_relax_section (abfd, sec, lin
}
/* If the branch and target are in the same section, you've
- got one honking big section and we can't help you. You'll
- get an error message later. */
- if (tsec == sec)
+ got one honking big section and we can't help you unless
+ you are branching backwards. You'll get an error message
+ later. */
+ if (tsec == sec && toff > roff)
continue;
/* Look for an existing fixup to this address. */
@@ -4542,13 +4543,37 @@ elfNN_ia64_relocate_section (output_bfd,
if (*name == '\0')
name = bfd_section_name (input_bfd, sym_sec);
}
- if (!(*info->callbacks->reloc_overflow) (info, &h->root,
- name, howto->name,
- (bfd_vma) 0,
- input_bfd,
- input_section,
- rel->r_offset))
- return FALSE;
+
+ switch (r_type)
+ {
+ case R_IA64_PCREL21B:
+ case R_IA64_PCREL21BI:
+ case R_IA64_PCREL21M:
+ case R_IA64_PCREL21F:
+ if (is_elf_hash_table (info->hash))
+ {
+ /* Relaxtion is always performed for ELF output.
+ Overflow failures for those relocations mean
+ that the section is too big to relax. */
+ (*_bfd_error_handler)
+ (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."),
+ input_bfd, input_section, howto->name, name,
+ rel->r_offset, input_section->size);
+ break;
+ }
+ default:
+ if (!(*info->callbacks->reloc_overflow) (info,
+ h ? &h->root : NULL,
+ name,
+ howto->name,
+ (bfd_vma) 0,
+ input_bfd,
+ input_section,
+ rel->r_offset))
+ return FALSE;
+ break;
+ }
+
ret_val = FALSE;
}
break;
More information about the Binutils
mailing list