OpenBSD: arm support (WIP)

This commit is contained in:
herman ten brugge 2021-01-13 13:20:36 +01:00
parent d5c78ce655
commit 23989cbcf3
3 changed files with 22 additions and 2 deletions

View File

@ -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:
{

View File

@ -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",

View File

@ -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);