From ee29b9fb005bee46f4d2504ad3a106421c4b882a Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Thu, 21 Mar 2002 15:26:03 +0000 Subject: [PATCH] * elf32-arm.h (elf32_arm_final_link_relocate case R_ARM_GOTOFF) (case R_ARM_GOT): Handle relocations to Thumb functions. --- bfd/ChangeLog | 5 +++++ bfd/elf32-arm.h | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bbff31d4fc9..884499405a6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2002-03-21 Richard Earnshaw + + * elf32-arm.h (elf32_arm_final_link_relocate case R_ARM_GOTOFF) + (case R_ARM_GOT): Handle relocations to Thumb functions. + 2002-03-21 Alan Modra * coff64-rs6000.c (_bfd_xcoff64_put_symbol_name): Prototype. diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index a452465ead2..04965412a00 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -1560,6 +1560,12 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, if (sgot == NULL) return bfd_reloc_notsupported; + /* If we are addressing a Thumb function, we need to adjust the + address by one, so that attempts to call the function pointer will + correctly interpret it as Thumb code. */ + if (sym_flags == STT_ARM_TFUNC) + value += 1; + /* Note that sgot->output_offset is not involved in this calculation. We always want the start of .got. If we define _GLOBAL_OFFSET_TABLE in a different way, as is @@ -1612,6 +1618,13 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, off &= ~1; else { + /* If we are addressing a Thumb function, we need to + adjust the address by one, so that attempts to + call the function pointer will correctly + interpret it as Thumb code. */ + if (sym_flags == STT_ARM_TFUNC) + value |= 1; + bfd_put_32 (output_bfd, value, sgot->contents + off); h->got.offset |= 1; } -- 2.30.2