Wanted to give a little update.
LD64: (1) I've found that with a few small changes to the code, LD64 no longer needs OpenSSL on OS X 10.4+, which greatly simplifies the dependency tree.
Attached is my patch.
(2) From looking at the change log, it seems that GCC 4.0+ anonymous symbols were removed in an earlier version, so it is no wonder that I was having problems with some binaries. I did some preliminary work on at least fixing the Bus Error, but this did not completely solve the issue since the files that caused the Bus Error ended up corrupted and won't load (attached is a separate patch in this regard just in case it may be helpful as a clue).
My guess is that this issue is caused by the removal of GCC 4.0 support, but I haven't expended the effort to look deeper into the problem since it seems that it is not an issue for others (who are using newer compilers) and for myself I've already found a different solution. But, if there is a huge interest, I may revisit re-adding the GCC 4 support back to LD64-97 at a later date and looking deeper into that Bus Error bug if that doesn't completely fix the problem.
However, for my own purposes, since I'm still using GCC 4.0 and just wanted 64-bit PowerPC memory support, I switched to version 62.1 of LD64, which works well and I was able to compile and run TenFourKit.
(3) I've also made a small patch (copy attached) to LD64 version 62 to remove all of the external dependencies. So if you can download the official Apple version of LD 64-62.1 and then apply my patch, you should be able to compile it as 64-bit PowerPC without issue and without external dependencies (if this is not the case, let me know).
OpenSSL: I've hit an important snag and think I will take a break for a bit.
There is clearly an issue with OpenSSL's assembler code as I've described with the .L/L local symbols. In the GNU AS manual (all versions from 1994-present), it suggests pretty clearly that these are intended for GCC (and other similar tools) and not really for hand-written assembler.
And for those using PowerPC Linux and BSD be forewarned that this problem in the assembler optimizations may affect your system, too (!) as described below, but as you will also see further below there's a major snag to fixing it...
The problems are technical but simple: The .L/L local symbols are discarded by GNU AS (i.e. address translation) before code segments are relocated. All versions of the GNU AS manual I've seen also warn that actual machine code may appear in a different order than what's written in the assembler files without making any guarantees or promises about whether/when this will occur. This causes a problem when the branch instruction is in a different code segment than the offset it's branching to.
For example:
Gets translated to:
However, if "Ltest:" and "bra Ltest" are in different sections and relocated after address translation, you end up with something like:
Casually, I'd like to call this a "shearing" of the branch since both the branch and its destination are "sheared" by moving relatively in opposite directions from one another.
And since the symbols are discarded by GNU AS (and even LD if you happened to use a different assembler), there is no way for the assembler / linker / OS to fix the broken reference.
However, two segments are not always independently relocated, so sometimes you will end-up wit the code branching where it's supposed to and other times you won't. It is this inconsistency why the OpenSSL team hasn't noticed a problem (yet) in PowerPC Linux.
And since the .L/L local symbols are largely undocumented, I've come to the conclusion from talking with the OpenSSL team and through my own compilation and disassembly that the warnings provided by GNU AS are minimal if there actually are any at all (since they are not expecting you to use them and GCC outputs GNU AS errors to the Terminal).
This is of course aside from any other potential issues which may exist from using the .L/L local symbols, since much of their behaviour is left undocumented in the GNU AS manual, or other issues that have yet found in the OpenSSL assembler code (considering the circumstances and its implications on code quality).
There are more .L/L local symbol branches than what I've done in this thread so-far. But to be clear, it is only the OpenSSL assembler optimizations which are affected, and these can be turned off at compilation time using with "no-asm" configuration parameter.
For reference, my proxy program is compiled with "no-asm" and using 32-bit PowerPC only and thus does not use the OpenSSL assembler optimizations.
The snag to fixing OpenSSL's code:
When I tried to communicate the problem to the OpenSSL team, the response missed the mark. The person reviewing the code and I are at a small impasse, where he doesn't want to make the change to the main branch and he has declined to have a technical discussion on the issue nor explain and elaborate on his position of why he wants to keep the Local symbols (or even use them in the first place) other than one comment about "not wanting to pollute the code with a global symbol" (which seems to be a possible misunderstanding on his part about what local symbols, local labels, and non-local symbols are and how they all work).
His main response is that he doesn't want to change it for anything but OS X because he hasn't "noticed a problem" in PowerPC Linux (despite him noting that he hasn't necessarily tested every line of code) and other various statements which show to me that while he may be a very talented cryptographer and likely a good C/C++ programmer, he simply doesn't understand the issue and doesn't seem receptive.
He has also hasn't seemed receptive to alternatives that would accommodate his view of symbols.
Nonetheless, to his full credit he is at least not opposed to having a fix for OS 10.4 specifically, although a CLA would be need to be signed and he seems to say that it would depend on also accepting the mpsuzuki patches (which were submitted in 2022(!) and thus their status is not clear to me).
Considering their response, I'm not confident in the quality of OpenSSL's PowerPC assembler code (including on Linux) and don't have the stamina to perform a full review of it.
So, I've determined that it is probably the safest just to turn off the assembler optimizations for now and worry about them later. After all, it's clear their strongest language is C/C++ and for something where security is paramount, you want the most secure version, even if it's at the expense of a little speed.
However, that said, and on the positive, I note that:
(a) the assembler optimizations don't yield that much of a performance benefit (at least not according to the code comments), so we aren't losing much;
(b) OpenSSL is no longer needed for building LD (with the above minor change);
And again (for those like me who are using it):
(c) my A.proxy program's included OpenSSL doesn't use the assembler optimizations at all (it's compiled with no-asm), so it should be unaffected.
Noting that we now seem to have a solution for 64-bit PowerPC LD64 (for Tiger and Leopard) and that OpenSSL works best with the assembler optimizations turned off, I think I'm now going to shift gears and see if I can fix MacIPX in the Classic Environment (for Command and Conquer). If anybody is interested in the MacIPX project, I've been mostly posting in this thread:
LD64: (1) I've found that with a few small changes to the code, LD64 no longer needs OpenSSL on OS X 10.4+, which greatly simplifies the dependency tree.
Attached is my patch.
(2) From looking at the change log, it seems that GCC 4.0+ anonymous symbols were removed in an earlier version, so it is no wonder that I was having problems with some binaries. I did some preliminary work on at least fixing the Bus Error, but this did not completely solve the issue since the files that caused the Bus Error ended up corrupted and won't load (attached is a separate patch in this regard just in case it may be helpful as a clue).
My guess is that this issue is caused by the removal of GCC 4.0 support, but I haven't expended the effort to look deeper into the problem since it seems that it is not an issue for others (who are using newer compilers) and for myself I've already found a different solution. But, if there is a huge interest, I may revisit re-adding the GCC 4 support back to LD64-97 at a later date and looking deeper into that Bus Error bug if that doesn't completely fix the problem.
However, for my own purposes, since I'm still using GCC 4.0 and just wanted 64-bit PowerPC memory support, I switched to version 62.1 of LD64, which works well and I was able to compile and run TenFourKit.
(3) I've also made a small patch (copy attached) to LD64 version 62 to remove all of the external dependencies. So if you can download the official Apple version of LD 64-62.1 and then apply my patch, you should be able to compile it as 64-bit PowerPC without issue and without external dependencies (if this is not the case, let me know).
OpenSSL: I've hit an important snag and think I will take a break for a bit.
There is clearly an issue with OpenSSL's assembler code as I've described with the .L/L local symbols. In the GNU AS manual (all versions from 1994-present), it suggests pretty clearly that these are intended for GCC (and other similar tools) and not really for hand-written assembler.
And for those using PowerPC Linux and BSD be forewarned that this problem in the assembler optimizations may affect your system, too (!) as described below, but as you will also see further below there's a major snag to fixing it...
The problems are technical but simple: The .L/L local symbols are discarded by GNU AS (i.e. address translation) before code segments are relocated. All versions of the GNU AS manual I've seen also warn that actual machine code may appear in a different order than what's written in the assembler files without making any guarantees or promises about whether/when this will occur. This causes a problem when the branch instruction is in a different code segment than the offset it's branching to.
For example:
Code:
02A Ltest: move D0,D1
.....
300 bra Ltest
....
Gets translated to:
Code:
02A move D0, D1
.....
300 bra #$FD28(PC) // i.e. 02A
However, if "Ltest:" and "bra Ltest" are in different sections and relocated after address translation, you end up with something like:
Code:
02A or.i $#00, D0 // i.e. some other block of code or even non-code (may not necessarily be "or.i $#00,D0" - this is just an example)
.....
300 bra #$FD28(PC) // i.e. 02A
....
34A move D0, D1 // where it should branch
Casually, I'd like to call this a "shearing" of the branch since both the branch and its destination are "sheared" by moving relatively in opposite directions from one another.
And since the symbols are discarded by GNU AS (and even LD if you happened to use a different assembler), there is no way for the assembler / linker / OS to fix the broken reference.
However, two segments are not always independently relocated, so sometimes you will end-up wit the code branching where it's supposed to and other times you won't. It is this inconsistency why the OpenSSL team hasn't noticed a problem (yet) in PowerPC Linux.
And since the .L/L local symbols are largely undocumented, I've come to the conclusion from talking with the OpenSSL team and through my own compilation and disassembly that the warnings provided by GNU AS are minimal if there actually are any at all (since they are not expecting you to use them and GCC outputs GNU AS errors to the Terminal).
This is of course aside from any other potential issues which may exist from using the .L/L local symbols, since much of their behaviour is left undocumented in the GNU AS manual, or other issues that have yet found in the OpenSSL assembler code (considering the circumstances and its implications on code quality).
There are more .L/L local symbol branches than what I've done in this thread so-far. But to be clear, it is only the OpenSSL assembler optimizations which are affected, and these can be turned off at compilation time using with "no-asm" configuration parameter.
For reference, my proxy program is compiled with "no-asm" and using 32-bit PowerPC only and thus does not use the OpenSSL assembler optimizations.
The snag to fixing OpenSSL's code:
When I tried to communicate the problem to the OpenSSL team, the response missed the mark. The person reviewing the code and I are at a small impasse, where he doesn't want to make the change to the main branch and he has declined to have a technical discussion on the issue nor explain and elaborate on his position of why he wants to keep the Local symbols (or even use them in the first place) other than one comment about "not wanting to pollute the code with a global symbol" (which seems to be a possible misunderstanding on his part about what local symbols, local labels, and non-local symbols are and how they all work).
His main response is that he doesn't want to change it for anything but OS X because he hasn't "noticed a problem" in PowerPC Linux (despite him noting that he hasn't necessarily tested every line of code) and other various statements which show to me that while he may be a very talented cryptographer and likely a good C/C++ programmer, he simply doesn't understand the issue and doesn't seem receptive.
He has also hasn't seemed receptive to alternatives that would accommodate his view of symbols.
Nonetheless, to his full credit he is at least not opposed to having a fix for OS 10.4 specifically, although a CLA would be need to be signed and he seems to say that it would depend on also accepting the mpsuzuki patches (which were submitted in 2022(!) and thus their status is not clear to me).
Considering their response, I'm not confident in the quality of OpenSSL's PowerPC assembler code (including on Linux) and don't have the stamina to perform a full review of it.
So, I've determined that it is probably the safest just to turn off the assembler optimizations for now and worry about them later. After all, it's clear their strongest language is C/C++ and for something where security is paramount, you want the most secure version, even if it's at the expense of a little speed.
However, that said, and on the positive, I note that:
(a) the assembler optimizations don't yield that much of a performance benefit (at least not according to the code comments), so we aren't losing much;
(b) OpenSSL is no longer needed for building LD (with the above minor change);
And again (for those like me who are using it):
(c) my A.proxy program's included OpenSSL doesn't use the assembler optimizations at all (it's compiled with no-asm), so it should be unaffected.
Noting that we now seem to have a solution for 64-bit PowerPC LD64 (for Tiger and Leopard) and that OpenSSL works best with the assembler optimizations turned off, I think I'm now going to shift gears and see if I can fix MacIPX in the Classic Environment (for Command and Conquer). If anybody is interested in the MacIPX project, I've been mostly posting in this thread: