ARM: 6963/1: Thumb-2: Relax relocation requirements for non-function symbols
[firefly-linux-kernel-4.4.55.git] / arch / arm / kernel / module.c
index fee7c36349eb6c137e7c578946968e20caf35910..016d6a0830a3e202bc42df7c40108a0875916d4b 100644 (file)
@@ -193,8 +193,17 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
                                offset -= 0x02000000;
                        offset += sym->st_value - loc;
 
-                       /* only Thumb addresses allowed (no interworking) */
-                       if (!(offset & 1) ||
+                       /*
+                        * For function symbols, only Thumb addresses are
+                        * allowed (no interworking).
+                        *
+                        * For non-function symbols, the destination
+                        * has no specific ARM/Thumb disposition, so
+                        * the branch is resolved under the assumption
+                        * that interworking is not required.
+                        */
+                       if ((ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&
+                               !(offset & 1)) ||
                            offset <= (s32)0xff000000 ||
                            offset >= (s32)0x01000000) {
                                pr_err("%s: section %u reloc %u sym '%s': relocation %u out of range (%#lx -> %#x)\n",