+2011-05-31  Paul Brook  <paul@codesourcery.com>
+
+       * elf32-arm.c (elf32_arm_final_link_relocate): Only do bl conversion
+       for known functions.
+       (elf32_arm_swap_symbol_in): Only set ST_BRANCH_TO_ARM for function
+       symbols.
+
 2011-05-31  Paul Brook  <paul@codesourcery.com>
 
        * elf32-arm.c (arm_stub_is_thumb): Add
 
                     case, mode switching is performed by the stub.  */
                  if (branch_type == ST_BRANCH_TO_THUMB && !stub_entry)
                    value |= (1 << 28);
-                 else
+                 else if (stub_entry || branch_type != ST_BRANCH_UNKNOWN)
                    {
                      value &= ~(bfd_vma)(1 << 28);
                      value |= (1 << 24);
 
   /* New EABI objects mark thumb function symbols by setting the low bit of
      the address.  */
-  if ((ELF_ST_TYPE (dst->st_info) == STT_FUNC
-       || ELF_ST_TYPE (dst->st_info) == STT_GNU_IFUNC)
-      && (dst->st_value & 1))
+  if (ELF_ST_TYPE (dst->st_info) == STT_FUNC
+      || ELF_ST_TYPE (dst->st_info) == STT_GNU_IFUNC)
     {
-      dst->st_value &= ~(bfd_vma) 1;
-      dst->st_target_internal = ST_BRANCH_TO_THUMB;
+      if (dst->st_value & 1)
+       {
+         dst->st_value &= ~(bfd_vma) 1;
+         dst->st_target_internal = ST_BRANCH_TO_THUMB;
+       }
+      else
+       dst->st_target_internal = ST_BRANCH_TO_ARM;
     }
   else if (ELF_ST_TYPE (dst->st_info) == STT_ARM_TFUNC)
     {
   else if (ELF_ST_TYPE (dst->st_info) == STT_SECTION)
     dst->st_target_internal = ST_BRANCH_LONG;
   else
-    dst->st_target_internal = ST_BRANCH_TO_ARM;
+    dst->st_target_internal = ST_BRANCH_UNKNOWN;
 
   return TRUE;
 }
 
+2011-05-31  Paul Brook  <paul@codesourcery.com>
+
+       * arm.h (arm_st_branch_type): Add ST_BRANCH_UNKNOWN.
+
 2011-04-15  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        * common.h (NT_STAPSDT): New define.
 
 enum arm_st_branch_type {
   ST_BRANCH_TO_ARM,
   ST_BRANCH_TO_THUMB,
-  ST_BRANCH_LONG
+  ST_BRANCH_LONG,
+  ST_BRANCH_UNKNOWN
 };
 
 #define ARM_SYM_BRANCH_TYPE(SYM) \
 
+2011-05-31  Paul Brook  <paul@codesourcery.com>
+
+       * ld-arm/cortex-a8-far.d: Adjust expected output.
+       * ld-arm/arm-call1.s: Give function symbol correct type.
+       * ld-arm/arm-call2.s: Ditto.
+       * ld-arm/farcall-group4.s: Ditto.
+       * ld-arm/arm-elf.exp (cortex-a8-far): Define far symbols with correct
+       type via assembly file.
+       * ld-arm/cortex-a8-far-3.s: New file.
+       * ld-arm/abs-call-1.s: Add Thumb tests
+
 2011-05-31  Paul Brook  <paul@codesourcery.com>
        Nathan Sidwell  <nathan@codesourcery.com>
 
 
 00008000 <arm>:
     8000:      eb03dffe        bl      100000 <foo>
     8004:      ea03dffd        b       100000 <foo>
-    8008:      eb03dffc        bl      100000 <foo>
+    8008:      fa03dffc        blx     100000 <foo>
+    800c:      eb03dffb        bl      100000 <foo>
+00008010 <thumb>:
+    8010:      f0f7 fff6       bl      100000 <foo>
+    8014:      f0f7 bff4       b\.w    100000 <foo>
+    8018:      f0f7 eff2       blx     100000 <foo>
 
 
 arm:   bl      0x100000
        b       0x100000
+       blx     0x100000
        bl      foo
 
+       .syntax unified
+       .thumb
+thumb: bl      0x100000
+       b       0x100000
+       blx     0x100000
+       @ bl foo is broken - gas fails to preserve the symbol reference
 
        .text
        .arch armv5t
        .global _start
+       .type _start, %function
 _start:
        bl arm
        bl t1
 
        .global t1
        .global t2
        .global t5
+       .type arm, %function
 arm:
        bx lr
        .thumb
 
      {{objdump -dr cortex-a8-fix-blx-rel-thumb.d}}
      "cortex-a8-fix-blx-rel-thumb"}
     {"Cortex-A8 erratum fix, relocate bl.w and far call"
-     "-EL -Ttext=0x00 --fix-cortex-a8 --defsym far_fn1=0x80000000 --defsym far_fn2=0x80000004  --defsym far_fn=0x7fff0000 --defsym _start=0"
-     "-EL -mcpu=cortex-a8" {cortex-a8-far-1.s cortex-a8-far-2.s}
+     "-EL -Ttext=0x00 --fix-cortex-a8 --defsym _start=0"
+     "-EL -mcpu=cortex-a8" {cortex-a8-far-1.s cortex-a8-far-2.s cortex-a8-far-3.s}
      {{objdump -dr cortex-a8-far.d}}
      "cortex-a8-far"}
     {"Cortex-A8 erratum fix, headers"
 
--- /dev/null
+.globl far_fn
+.type far_fn, %function
+.set far_fn, 0x7fff0000
+.globl far_fn1
+.type far_fn1, %function
+.set far_fn1, 0x80000000
+.globl far_fn2
+.type far_fn2, %function
+.set far_fn2, 0x80000004
 
        bl bar
 
        .section .far, "xa"
+       .type bar, %function
        .global bar
 bar:
        bx lr