>From FreeBSD, still under GPLv2. I've seen R_ARM_MOVW_ABS_NC in code
generated by clang.
ok?
Index: gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h,v
retrieving revision 1.6
diff -u -p -r1.6 bfd-in2.h
--- gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h 31 May 2016 17:05:03 -0000
1.6
+++ gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h 19 Sep 2016 09:17:38 -0000
@@ -2907,6 +2907,12 @@ pc-relative or some form of GOT-indirect
/* 31-bit PC relative address. */
BFD_RELOC_ARM_PREL31,
+/* Low and High halfword relocations for MOVW and MOVT instructions. */
+ BFD_RELOC_ARM_MOVW,
+ BFD_RELOC_ARM_MOVT,
+ BFD_RELOC_ARM_MOVW_PCREL,
+ BFD_RELOC_ARM_MOVT_PCREL,
+
/* Relocations for setting up GOTs and PLTs for shared libraries. */
BFD_RELOC_ARM_JUMP_SLOT,
BFD_RELOC_ARM_GLOB_DAT,
Index: gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c,v
retrieving revision 1.2
diff -u -p -r1.2 elf32-arm.c
--- gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c 26 Jun 2015 04:28:53 -0000
1.2
+++ gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c 19 Sep 2016 09:17:38 -0000
@@ -1366,6 +1366,10 @@ static const struct elf32_arm_reloc_map
{BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32},
{BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT},
{BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY},
+ {BFD_RELOC_ARM_MOVW, R_ARM_MOVW_ABS_NC},
+ {BFD_RELOC_ARM_MOVT, R_ARM_MOVT_ABS},
+ {BFD_RELOC_ARM_MOVW_PCREL, R_ARM_MOVW_PREL_NC},
+ {BFD_RELOC_ARM_MOVT_PCREL, R_ARM_MOVT_PREL},
};
static reloc_howto_type *
@@ -4080,6 +4084,49 @@ elf32_arm_final_link_relocate (reloc_how
}
return bfd_reloc_ok;
+ case R_ARM_MOVW_ABS_NC:
+ case R_ARM_MOVT_ABS:
+ case R_ARM_MOVW_PREL_NC:
+ case R_ARM_MOVT_PREL:
+ /* Until we properly support segment-base-relative addressing then
+ we assume the segment base to be zero, as for the group relocations.
+ Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC
+ and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */
+ case R_ARM_MOVW_BREL_NC:
+ case R_ARM_MOVW_BREL:
+ case R_ARM_MOVT_BREL:
+ {
+ bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
+
+ if (globals->use_rel)
+ {
+ addend = ((insn >> 4) & 0xf000) | (insn & 0xfff);
+ signed_addend = (addend ^ 0x8000) - 0x8000;
+ }
+
+ value += signed_addend;
+
+ if (r_type == R_ARM_MOVW_PREL_NC || r_type == R_ARM_MOVT_PREL)
+ value -= (input_section->output_section->vma
+ + input_section->output_offset + rel->r_offset);
+
+ if (r_type == R_ARM_MOVW_BREL && value >= 0x10000)
+ return bfd_reloc_overflow;
+
+ if (sym_flags == STT_ARM_TFUNC)
+ value |= 1;
+
+ if (r_type == R_ARM_MOVT_ABS || r_type == R_ARM_MOVT_PREL
+ || r_type == R_ARM_MOVT_BREL)
+ value >>= 16;
+
+ insn &= 0xfff0f000;
+ insn |= value & 0xfff;
+ insn |= (value & 0xf000) << 4;
+ bfd_put_32 (input_bfd, insn, hit_data);
+ }
+ return bfd_reloc_ok;
+
default:
return bfd_reloc_notsupported;
}
@@ -5651,6 +5698,10 @@ elf32_arm_gc_sweep_hook (bfd *
case R_ARM_JUMP24:
case R_ARM_PREL31:
case R_ARM_THM_CALL:
+ case R_ARM_MOVW_ABS_NC:
+ case R_ARM_MOVT_ABS:
+ case R_ARM_MOVW_PREL_NC:
+ case R_ARM_MOVT_PREL:
/* Should the interworking branches be here also? */
if (h != NULL)
@@ -5861,6 +5912,10 @@ elf32_arm_check_relocs (bfd *abfd, struc
case R_ARM_JUMP24:
case R_ARM_PREL31:
case R_ARM_THM_CALL:
+ case R_ARM_MOVW_ABS_NC:
+ case R_ARM_MOVT_ABS:
+ case R_ARM_MOVW_PREL_NC:
+ case R_ARM_MOVT_PREL:
/* Should the interworking branches be listed here? */
if (h != NULL)
{
Index: gnu/usr.bin/binutils-2.17/bfd/libbfd.h
===================================================================
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/libbfd.h,v
retrieving revision 1.5
diff -u -p -r1.5 libbfd.h
--- gnu/usr.bin/binutils-2.17/bfd/libbfd.h 31 May 2016 17:05:03 -0000
1.5
+++ gnu/usr.bin/binutils-2.17/bfd/libbfd.h 19 Sep 2016 09:17:38 -0000
@@ -1209,6 +1209,10 @@ static const char *const bfd_reloc_code_
"BFD_RELOC_ARM_SBREL32",
"BFD_RELOC_ARM_TARGET2",
"BFD_RELOC_ARM_PREL31",
+ "BFD_RELOC_ARM_MOVW",
+ "BFD_RELOC_ARM_MOVT",
+ "BFD_RELOC_ARM_MOVW_PCREL",
+ "BFD_RELOC_ARM_MOVT_PCREL",
"BFD_RELOC_ARM_JUMP_SLOT",
"BFD_RELOC_ARM_GLOB_DAT",
"BFD_RELOC_ARM_GOT32",
Index: gnu/usr.bin/binutils-2.17/bfd/reloc.c
===================================================================
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c,v
retrieving revision 1.2
diff -u -p -r1.2 reloc.c
--- gnu/usr.bin/binutils-2.17/bfd/reloc.c 25 May 2015 14:56:26 -0000
1.2
+++ gnu/usr.bin/binutils-2.17/bfd/reloc.c 19 Sep 2016 09:17:38 -0000
@@ -2705,6 +2705,14 @@ ENUM
BFD_RELOC_ARM_PREL31
ENUMDOC
31-bit PC relative address.
+ENUM
+ BFD_RELOC_ARM_MOVW
+ENUMX
+ BFD_RELOC_ARM_MOVT
+ENUMX
+ BFD_RELOC_ARM_MOVW_PCREL
+ENUMX
+ BFD_RELOC_ARM_MOVT_PCREL
ENUM
BFD_RELOC_ARM_JUMP_SLOT