Conversation
|
also worth noting i based this off the v6.0.1 release so there are extraneous commits in here for some reason |
|
Just rebase onto master |
This also removes .init/.fini constructors as they're not needed
no92
left a comment
There was a problem hiding this comment.
First pass on everything but the assembly.
A few general notes:
- reformatting the codebase in this PR is out of scope, splitting that into its own PR would be reasonable
- squashing the two remaining commits would be nice, too
- the indent on assembly files is mixed
I don't know too much about ppc64 assembly so I'll have to read up on that first.
| #define FE_DOWNWARD 0b11 | ||
| #define FE_TOWARDZERO 0b01 | ||
| #define FE_UPWARD 0b10 |
There was a problem hiding this comment.
Binary literals are compiler extensions and should therefore not be used in public headers.
| #endif | ||
| #if defined(__powerpc64__) | ||
| case DT_LOPROC: | ||
| case 0x70000003: // unknown |
There was a problem hiding this comment.
From binutils source, this seems to be DT_PPC64_OPT which specifies what optimizations can be used with the ELFv2 ABI.
| } | ||
| #else | ||
| #elif defined(__powerpc64__) | ||
| // ppc64 elfv1 can't rely on the OPD before relocations, therefore calling the getLdsoBase function |
There was a problem hiding this comment.
I wonder if we could just force-inline the function on ppc64?
| } | ||
| #if defined(__powerpc64__) | ||
| case DT_LOPROC: | ||
| case 0x70000003: // unknown |
| @@ -0,0 +1 @@ | |||
| #pragma once | |||
| // tcbhead->hwcap_extn = (static_cast<uint64_t>(aux_vec.at_hwcap3) << 32) | | ||
| // aux_vec.at_hwcap4; tcbhead->at_platform = aux_vec.at_platform; | ||
|
|
||
| uintptr_t thread_data = reinterpret_cast<uintptr_t>(pointer) + 0x7000 + sizeof(Tcb); |
There was a problem hiding this comment.
It would be preferable to use the constant for the TCB offset.
| #elif defined(__powerpc64__) | ||
| // TP should point to the address 0x7000 bytes after the TCB. | ||
| // TODO: We should change the sysdep so that we don't need to do this. | ||
| auto tp = reinterpret_cast<char *>(tcb) + sizeof(Tcb) + 0x7000; |
| // tcbhead_t* tcbhead = reinterpret_cast<tcbhead_t*>(reinterpret_cast<uintptr_t>(pointer) - | ||
| // sizeof(tcbhead_t)); const auto& aux_vec = get_aux_vec(); | ||
| // tcbhead->hwcap = (static_cast<uint64_t>(aux_vec.at_hwcap) << 32) | aux_vec.at_hwcap2; | ||
| // tcbhead->hwcap_extn = (static_cast<uint64_t>(aux_vec.at_hwcap3) << 32) | | ||
| // aux_vec.at_hwcap4; tcbhead->at_platform = aux_vec.at_platform; |
There was a problem hiding this comment.
Why is hwcap setup done here instead of somewhere further up the callchain?
There was a problem hiding this comment.
no clue tbh where it should be done
| auto tp = reinterpret_cast<char *>(tcb) + sizeof(Tcb) - 0x10; | ||
| tcb = reinterpret_cast<void *>(tp); | ||
| #elif defined(__powerpc64__) | ||
| // TP should point to the address 0x7000 bytes after the TCB. |
| struct shmid_ds { | ||
| struct ipc_perm shm_perm; | ||
| time_t shm_atime; | ||
| time_t shm_dtime; | ||
| time_t shm_ctime; | ||
| size_t shm_segsz; | ||
| pid_t shm_cpid; | ||
| pid_t shm_lpid; | ||
| unsigned long shm_nattch; | ||
| unsigned long __unused[2]; | ||
| }; |
There was a problem hiding this comment.
I'm not sure this is correct - this seems to match the definition of shmid64_ds for ppc64, which is a different struct. I think the correct definition is the one above.
This PR adds almost complete ppc64 support to mlibc. There are mainly two issues with this port currently:
I am also currently not sure if ppc64 support compiles on anything but my custom fork of llvm, so there might be dragons there. I will test it with gcc at some point and report the results. Considering the compilation difficulties I am first creating this as a draft PR so that code can be gradually reviewed.