Committed, fix ld/1567, 64-bit vma overflow signalled from 32-bit-target address-wrap.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Committed, fix ld/1567, 64-bit vma overflow signalled from 32-bit-target address-wrap.

Hans-Peter Nilsson
See the elf32-cris.c comment and the test-case, distilled from
the Linux error case.  I'm a bit undecided whether ld/bfd itself
should truncate for 32-bit addresses here.  Maybe the offset
should have been sign-extended instead of zero-extended.
Anyway, it's easy enough to just make the reloc type decide what
can be an overflow.

bfd:
        PR ld/1567
        * elf32-cris.c (cris_elf_howto_table) <R_CRIS_32>: Set
        complain_on_overflow field to complain_overflow_dont.

ld/testsuite:
        PR ld/1567
        * ld-cris/noov.s, ld-cris/noov.d: New test.

Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.70
diff -p -u -r1.70 elf32-cris.c
--- elf32-cris.c 18 Aug 2005 01:28:22 -0000 1.70
+++ elf32-cris.c 28 Oct 2005 00:15:55 -0000
@@ -156,7 +156,12 @@ static reloc_howto_type cris_elf_howto_t
  32, /* bitsize */
  FALSE, /* pc_relative */
  0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
+ /* We don't want overflow complaints for 64-bit vma builds
+    for e.g. sym+0x40000000 (or actually sym-0xc0000000 in
+    32-bit ELF) where sym=0xc0001234.
+    Don't do this for the PIC relocs, as we don't expect to
+    see them with large offsets.  */
+ complain_overflow_dont, /* complain_on_overflow */
  bfd_elf_generic_reloc, /* special_function */
  "R_CRIS_32", /* name */
  FALSE, /* partial_inplace */
--- /dev/null 2005-10-24 09:14:21.072379500 +0200
+++ noov.d 2005-10-28 02:14:31.000000000 +0200
@@ -0,0 +1,13 @@
+#notarget: cris-*-*aout*
+#ld: --section-start=.text=0xc0010000
+#objdump: -s -j .text
+
+# Check that we don't get a "relocation truncated to fit", when a
+# relocation would overflow if it hadn't been wrapping.  We always
+# want 32-bit-wrapping on a 32-bit target for the benefit of Linux
+# address-mapping macros.
+
+.*:     file format elf32.*-cris
+
+Contents of section \.text:
+ c0010000 04200100 00200100                    .*
--- /dev/null 2005-10-24 09:14:21.072379500 +0200
+++ noov.s 2005-10-28 02:14:23.000000000 +0200
@@ -0,0 +1,14 @@
+ .text
+ ; Test that this works both with a symbol defined in a section...
+ .dword __Edata+0x40000000
+
+ ; ...as well as absolute symbol (defined outside sections in the
+ ; linker script).
+ .dword __Sdata+0x40000000
+
+ .data
+ ; Make sure we get the same section alignment for *-elf as for *-linux*.
+ .balign 0x2000
+
+ ; Make .data non-empty.
+ .dword 0

brgds, H-P