Compare commits

..

No commits in common. "8ea0a6728081b9b18c2f4aca508712b06d7b08d9" and "00c682082522fad13a92d94b56fcc5154deda735" have entirely different histories.

4 changed files with 16 additions and 27 deletions

View File

@ -64,6 +64,10 @@ target_compile_definitions(objlibc PRIVATE __arch=${BANAN_ARCH})
target_compile_options(objlibc PRIVATE -O2 -g -Wstack-usage=512 -fno-exceptions -fpic -nolibc)
target_compile_options(objlibc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)
if("${BANAN_ARCH}" STREQUAL "i686")
target_compile_definitions(objlibc PRIVATE __disable_thread_local_storage)
endif()
function(add_crtx crtx)
add_custom_target(${crtx}
COMMAND ${CMAKE_CXX_COMPILER} -c -o ${CMAKE_INSTALL_LIBDIR}/${crtx}.o ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/${crtx}.S

View File

@ -105,6 +105,7 @@ void pthread_cleanup_push(void (*routine)(void*), void* arg)
uthread->cleanup_stack = cleanup;
}
#if not __disable_thread_local_storage
static thread_local struct {
void* value;
void (*destructor)(void*);
@ -158,6 +159,7 @@ int pthread_setspecific(pthread_key_t key, const void* value)
s_pthread_keys[key].value = const_cast<void*>(value);
return 0;
}
#endif
int pthread_attr_destroy(pthread_attr_t* attr)
{
@ -411,6 +413,7 @@ void pthread_exit(void* value_ptr)
while (uthread->cleanup_stack)
pthread_cleanup_pop(1);
#if not __disable_thread_local_storage
for (size_t iteration = 0; iteration < PTHREAD_DESTRUCTOR_ITERATIONS; iteration++)
{
bool called = false;
@ -428,6 +431,7 @@ void pthread_exit(void* value_ptr)
if (!called)
break;
}
#endif
free_uthread(uthread);
syscall(SYS_PTHREAD_EXIT, value_ptr);
@ -1195,6 +1199,7 @@ int pthread_barrier_wait(pthread_barrier_t* barrier)
return 0;
}
#if not __disable_thread_local_storage
struct tls_index
{
unsigned long int ti_module;
@ -1209,6 +1214,7 @@ extern "C" void* __tls_get_addr(tls_index* ti)
#if ARCH(i686)
extern "C" void* __attribute__((__regparm__(1))) ___tls_get_addr(tls_index* ti)
{
return reinterpret_cast<void*>(_get_uthread()->dtv[ti->ti_module] + ti->ti_offset);
return reinterpret_cast<void*>(get_uthread()->dtv[ti->ti_module] + ti->ti_offset);
}
#endif
#endif

View File

@ -338,6 +338,7 @@ static void handle_tls_relocation(const LoadedElf& elf, const RelocT& reloc)
if (elf.tls_addr == nullptr)
print_error_and_exit("tls relocation without tls", 0);
#if defined(__x86_64__)
switch (ELF64_R_TYPE(reloc.r_info))
{
@ -606,27 +607,7 @@ static void relocate_elf(LoadedElf& elf, bool lazy_load)
#error "unsupported architecture"
#endif
bool do_relocation = false;
if (const uint32_t symbol_index = ELF_R_SYM(info))
{
const auto& symbol = *reinterpret_cast<ElfNativeSymbol*>(elf.symtab + symbol_index * elf.syment);
const char* symbol_name = reinterpret_cast<const char*>(elf.strtab + symbol.st_name);
if (strcmp(symbol_name, "__tls_get_addr") == 0 || strcmp(symbol_name, "___tls_get_addr") == 0)
do_relocation = true;
}
if (!do_relocation)
*reinterpret_cast<uintptr_t*>(elf.base + offset) += elf.base;
else switch (elf.pltrel)
{
case DT_REL:
handle_relocation(elf, reinterpret_cast<ElfNativeRelocation*>(elf.jmprel)[i], true);
break;
case DT_RELA:
handle_relocation(elf, reinterpret_cast<ElfNativeRelocationA*>(elf.jmprel)[i], true);
break;
}
*reinterpret_cast<uintptr_t*>(elf.base + offset) += elf.base;
}
}
}
@ -1082,6 +1063,9 @@ static MasterTLS initialize_master_tls()
static void initialize_tls(MasterTLS master_tls)
{
if (master_tls.addr == nullptr)
return;
const size_t tls_size = master_tls.size
+ sizeof(uthread)
+ (master_tls.module_count + 1) * sizeof(uintptr_t);

View File

@ -687,11 +687,6 @@ Rectangle Terminal::putcodepoint(uint32_t codepoint)
case '\r':
m_cursor.x = 0;
break;
case '\t':
m_cursor.x++;
while (m_cursor.x % 8)
m_cursor.x++;
break;
case '\b':
if (m_cursor.x > 0)
m_cursor.x--;