diff --git a/arm-link.c b/arm-link.c index bad4e8b9..1901eb93 100644 --- a/arm-link.c +++ b/arm-link.c @@ -46,6 +46,8 @@ int code_reloc (int reloc_type) case R_ARM_GLOB_DAT: case R_ARM_NONE: case R_ARM_TARGET1: + case R_ARM_MOVT_PREL: + case R_ARM_MOVW_PREL_NC: return 0; case R_ARM_PC24: @@ -89,6 +91,8 @@ int gotplt_entry_type (int reloc_type) case R_ARM_REL32: case R_ARM_V4BX: case R_ARM_TARGET1: + case R_ARM_MOVT_PREL: + case R_ARM_MOVW_PREL_NC: return AUTO_GOTPLT_ENTRY; case R_ARM_GOTPC: @@ -332,6 +336,20 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t *(int *)ptr += x; } return; + case R_ARM_MOVT_PREL: + case R_ARM_MOVW_PREL_NC: + { + int insn = *(int *)ptr; + int addend = ((insn >> 4) & 0xf000) | (insn & 0xfff); + + addend = (addend ^ 0x8000) - 0x8000; + val += addend - addr; + if (type == R_ARM_MOVT_PREL) + val >>= 16; + *(int *)ptr = (insn & 0xfff0f000) | + ((val & 0xf000) << 4) | (val & 0xfff); + } + return; case R_ARM_THM_MOVT_ABS: case R_ARM_THM_MOVW_ABS_NC: { diff --git a/lib/bcheck.c b/lib/bcheck.c index a880a216..dedb753d 100644 --- a/lib/bcheck.c +++ b/lib/bcheck.c @@ -289,7 +289,7 @@ DLL_EXPORT char *__bound_strcat(char *dest, const char *src); DLL_EXPORT char *__bound_strchr(const char *string, int ch); DLL_EXPORT char *__bound_strdup(const char *s); -#if defined(__arm__) +#if defined(__arm__) && defined(TCC_ARM_EABI) DLL_EXPORT void *__bound___aeabi_memcpy(void *dst, const void *src, size_t size); DLL_EXPORT void *__bound___aeabi_memmove(void *dst, const void *src, size_t size); DLL_EXPORT void *__bound___aeabi_memmove4(void *dst, const void *src, size_t size); @@ -1738,7 +1738,7 @@ void *__bound_memset(void *s, int c, size_t n) return memset(s, c, n); } -#if defined(__arm__) +#if defined(__arm__) && defined(TCC_ARM_EABI) void *__bound___aeabi_memcpy(void *dest, const void *src, size_t n) { dprintf(stderr, "%s, %s(): %p, %p, 0x%lx\n", diff --git a/tccelf.c b/tccelf.c index de06af21..2119d9b6 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1387,6 +1387,8 @@ ST_FUNC void tcc_add_btstub(TCCState *s1) CString cstr; s = data_section; + /* Align to PTR_SIZE */ + section_ptr_add(s, -s->data_offset & (PTR_SIZE - 1)); o = s->data_offset; /* create (part of) a struct rt_context (see tccrun.c) */ put_ptr(s1, stab_section, 0);