]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
09-03-05 Christophe Lyon <christophe.lyon@st.com>
authorChristophe Lyon <christophe.lyon@st.com>
Fri, 6 Mar 2009 08:57:58 +0000 (08:57 +0000)
committerChristophe Lyon <christophe.lyon@st.com>
Fri, 6 Mar 2009 08:57:58 +0000 (08:57 +0000)
bfd/
* elf32-arm.c (group_sections): Take next section size into
account before accepting to group it.

testsuite/
* ld-arm/arm-elf.exp: Add new farcall-group-limit test.
* ld-arm/farcall-group-limit.d: New file.
* ld-arm/farcall-group3.s: New file.
* ld-arm/farcall-group4.s: New file.

bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/farcall-group-limit.d [new file with mode: 0644]
ld/testsuite/ld-arm/farcall-group3.s [new file with mode: 0644]
ld/testsuite/ld-arm/farcall-group4.s [new file with mode: 0644]

index bc12f9f328e2dd7456dc1c7d869f0dd68db65c13..f15e157dd80edbe0c2402640592b2fdfcc4c6b7a 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-05  Christophe Lyon  <christophe.lyon@st.com>
+
+       * elf32-arm.c (group_sections): Take next section size into
+       account before accepting to group it.
+
 2009-03-05  Christophe Lyon  <christophe.lyon@st.com>
 
        * elf32-arm.c (arm_type_of_stub): Handle long branches targetting
index 607ba04adaa7a6c269e138d40fcb43a9adee1cf3..f534290ee87799c4ee89a9f897c3ec6d361d2eb0 100644 (file)
@@ -3554,11 +3554,20 @@ group_sections (struct elf32_arm_link_hash_table *htab,
          bfd_size_type total;
 
          curr = head;
-         total = head->size;
-         while ((next = NEXT_SEC (curr)) != NULL
-                && ((total += next->output_offset - curr->output_offset)
-                    < stub_group_size))
+         total = 0;
+         while ((next = NEXT_SEC (curr)) != NULL)
+           {
+             if ( (total + next->output_offset - curr->output_offset
+                   + next->size)
+                  < stub_group_size )
+               {
+                 total += next->output_offset - curr->output_offset;
+               }
+             else
+               break;
+
            curr = next;
+           }
 
          /* OK, the size from the start to the start of CURR is less
             than stub_group_size and thus can be handled by one stub
@@ -3579,11 +3588,18 @@ group_sections (struct elf32_arm_link_hash_table *htab,
             bytes after the stub section can be handled by it too.  */
          if (!stubs_always_after_branch)
            {
-             total = 0;
-             while (next != NULL
-                    && ((total += next->output_offset - head->output_offset)
-                        < stub_group_size))
+             total = head->size;
+             while (next != NULL)
                {
+                 if ( (total + next->output_offset - head->output_offset
+                       + next->size)
+                      < stub_group_size )
+                   {
+                     total += next->output_offset - head->output_offset;
+                   }
+                 else
+                   break;
+
                  head = next;
                  next = NEXT_SEC (head);
                  htab->stub_group[head->id].link_sec = curr;
index 693a93bde9b18e97eb4a3155badc500e417b671a..9c9f1e7bc3bc31a195d876f87f182191cdd6ef02 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-05  Christophe Lyon  <christophe.lyon@st.com>
+
+       * ld-arm/arm-elf.exp: Add new farcall-group-limit test.
+       * ld-arm/farcall-group-limit.d: New file.
+       * ld-arm/farcall-group3.s: New file.
+       * ld-arm/farcall-group4.s: New file.
+
 2009-03-05  Christophe Lyon  <christophe.lyon@st.com>
 
        * ld-arm/arm-elf.exp: Add 2 more tests to check long branch stubs
index 0dfc44188ceb6b9a3796a84dbd0666ffed81d5e4..b9c7513a502c1b2f8b4d9940be7c2d8d5cb399e4 100644 (file)
@@ -338,6 +338,9 @@ set armeabitests {
     {"Group size=2" "-Ttext 0x1000 --section-start .foo=0x2003020 --stub-group-size=2" "" {farcall-group.s farcall-group2.s}
      {{objdump -d farcall-group-size2.d}}
      "farcall-group-size2"}
+    {"Group size limit" "-Ttext 0x1000 --section-start .far=0x2003020" "" {farcall-group3.s farcall-group4.s}
+     {{objdump -d farcall-group-limit.d}}
+     "farcall-group-limit"}
 
     {"Mixed ARM/Thumb dynamic application with farcalls" "tmpdir/mixed-lib.so -T arm-dyn.ld --section-start .far_arm=0x2100000 --section-start .far_thumb=0x2200000" ""
      {farcall-mixed-app.s}
diff --git a/ld/testsuite/ld-arm/farcall-group-limit.d b/ld/testsuite/ld-arm/farcall-group-limit.d
new file mode 100644 (file)
index 0000000..204dcd8
--- /dev/null
@@ -0,0 +1,21 @@
+
+.*:     file format .*
+
+Disassembly of section .text:
+
+00001000 <_start>:
+    1000:      eb000000        bl      1008 <__bar_veneer>
+    1004:      00000000        andeq   r0, r0, r0
+
+00001008 <__bar_veneer>:
+    1008:      e51ff004        ldr     pc, \[pc, #-4\] ; 100c <__bar_veneer\+0x4>
+    100c:      02003020        .word   0x02003020
+
+00001010 <myfunc>:
+       ...
+ 2001010:      eb000802        bl      2003020 <bar>
+
+Disassembly of section .far:
+
+02003020 <bar>:
+ 2003020:      e12fff1e        bx      lr
diff --git a/ld/testsuite/ld-arm/farcall-group3.s b/ld/testsuite/ld-arm/farcall-group3.s
new file mode 100644 (file)
index 0000000..ea2ce7f
--- /dev/null
@@ -0,0 +1,9 @@
+@ Test to ensure that ARM calls exceeding 32Mb generate stubs,
+@ and that stubs are correctly inserted between input sections
+@ when one contribution size exceeds the limit.
+
+       .text
+       .global bar
+       .global _start
+_start:
+       bl bar
diff --git a/ld/testsuite/ld-arm/farcall-group4.s b/ld/testsuite/ld-arm/farcall-group4.s
new file mode 100644 (file)
index 0000000..17f503b
--- /dev/null
@@ -0,0 +1,13 @@
+@ Test to ensure that ARM calls exceeding 32Mb generate stubs,
+@ and that a large input section forces stub insertion before its
+@ contribution.
+
+       .text
+myfunc:
+       .space 0x2000000
+       bl bar
+
+       .section .far, "xa"
+       .global bar
+bar:
+       bx lr