-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libphoenix: compile with FPIC by default
JIRA: RTOS-664
- Loading branch information
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* libphoenix | ||
* | ||
* tls access function | ||
* | ||
* Copyright 2023 Phoenix Systems | ||
* Author: Hubert Badocha | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
|
||
#define TLS_TCB_SIZE 8 | ||
|
||
|
||
typedef struct { | ||
unsigned long ti_moduleid; | ||
unsigned long ti_tlsoffset; | ||
} TLS_index; | ||
|
||
|
||
/* When libphoenix is compiled as a PIC, even when linked into a static NOPIC binary, | ||
* compiler generates accesses to TLS as calls to this function. | ||
* This functions is simple version just for static binaries purposes, | ||
* in dynamic binaries dynamic linker handles TLS accesses. */ | ||
void *__tls_get_addr(TLS_index *ti) | ||
{ | ||
void *ptr; | ||
__asm__ volatile ("mrc p15, 0, %0, cr13, cr0, 3" | ||
: "=r"(ptr)); | ||
return ((char *)ptr) + TLS_TCB_SIZE + ti->ti_tlsoffset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* libphoenix | ||
* | ||
* tls access function | ||
* | ||
* Copyright 2023 Phoenix Systems | ||
* Author: Hubert Badocha | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
|
||
typedef struct { | ||
unsigned long ti_moduleid; | ||
unsigned long ti_tlsoffset; | ||
} TLS_index; | ||
|
||
|
||
/* When libphoenix is compiled as a PIC, even when linked into a static NOPIC binary, | ||
* compiler generates accesses to TLS as calls to this function. | ||
* This functions is simple version just for static binaries purposes, | ||
* in dynamic binaries dynamic linker handles TLS accesses. */ | ||
void *__tls_get_addr(TLS_index *ti) | ||
{ | ||
void *ptr; | ||
__asm__ volatile ("mv %0, tp" | ||
: "=r"(ptr)); | ||
/* GCC expects that Dynamic Thread Vector pointer points at TLS block start + 0x800 */ | ||
return ((char *)ptr) + ti->ti_tlsoffset + 0x800; | ||
} |