Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

undefined reference to __aeabi_read_tp on ModuleCtors #25

Open
MrcSnm opened this issue Jun 4, 2022 · 4 comments
Open

undefined reference to __aeabi_read_tp on ModuleCtors #25

MrcSnm opened this issue Jun 4, 2022 · 4 comments

Comments

@MrcSnm
Copy link
Contributor

MrcSnm commented Jun 4, 2022

In dub.json I have:

"dflags": [
		"-mtriple=armv7a-unknown-unknown",
		"-mcpu=cortex-a9",
		"-g",
		"-float-abi=hard",
		"-O0",
		"--boundscheck=off",
		"-fthread-model=local-exec"
	],

"versions": [
		"LWDR_DynamicArray",
		"LWDR_ModuleCtors"
	],

My D code:

class Test
{
	static int[] testStaticConstructor;
	immutable(char*) getStringFromD()
	{
		return "Hello World from D! Simple Test".ptr;
	}
}

static this()
{
	for(int i = 0; i < 5; i++)
		Test.testStaticConstructor~= i;
}
@MrcSnm
Copy link
Contributor Author

MrcSnm commented Jun 4, 2022

So, I found the thing about the TLS thing, so I implemented the functions as this on my C code:

#define MAX_THREADS 32
thread_key_t tls_keys[MAX_THREADS];

#define CHECK_CREATE_KEY(index) if((index) > MAX_THREADS || (index) < 0) \
									assert(0); \
								if(tls_keys[index] == NULL) \
									pthread_key_create(&tls_keys[index], NULL);


void* rtosbackend_getTLSPointerCurrThread(int index)
{
	CHECK_CREATE_KEY(index);
	return pthread_getspecific(tls_keys[index]);
	//SCE -> return sceKernelGetTLSAddr(index);
}
void rtosbackend_setTLSPointerCurrThread(void* value, int index)
{
	CHECK_CREATE_KEY(index);
	pthread_setspecific(tls_keys[index], value);
}

But now I'm getting an error called Invalid relocation type

@MrcSnm
Copy link
Contributor Author

MrcSnm commented Jun 4, 2022

After some people said to me, I should have no Position Independent Code.

So I went and added to DFLAGS: --relocation-model=static. But nothing actually had changed

@MrcSnm
Copy link
Contributor Author

MrcSnm commented Jun 4, 2022

So, after putting __gshared on my class, I got rid of the error (Invalid relocation type). But, is that really the expected behaviour?

class Test
{
	__gshared static int[] testStaticConstructor;
	immutable(char*) getStringFromD()
	{
		return "Hello World from D! Simple Test".ptr;
	}
}

But my static this is not being called.
Have you implemented it? My code is unable to reference Runtime.initialize nor rt_init

@MrcSnm
Copy link
Contributor Author

MrcSnm commented Jun 4, 2022

Okay, it seems you have implemented that under the beta version.
Maybe we could have that under a changelog?

Okay. I found that

import lwdr;
void main()
{
     LWDR.startRuntime();
     LWDR.stopRuntime();
}

But then...:

c:/msys64/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld.exe: libDLibrary.a(rt.moduleinfo.o): in function `_D2rt10moduleinfo9sortCtorsFNbNiZ8findDepsMFNbNikPkZb':
C:\/Users\Marcelo\AppData\Local\dub\packages\lwdr-0.4.0-beta.1\lwdr\source\rt/moduleinfo.d:143: undefined reference to `_d_eh_resume_unwind'
c:/msys64/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld.exe: libDLibrary.a(rt.moduleinfo.o):(.ARM.extab+0x0): undefined reference to `_d_eh_personality'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant