Hi,
Let me explain again on what needs for earmv6{,hf}eb support for GCC.
ARMv6 supports both BE32 (deprecated) and BE8 (new) formats for
big-endian mode. While other OS's use BE8 on ARMv6, our code is
intended to use BE32 instead.
Therefore, we need to
(1) Do not emit --be8 linker flag for ARMv6 by default.
(2) Disable unaligned access for big-endian mode on ARMv6 by default.
Even though ARMv6 supports unaligned access, it cannot be used with
BE32, cf.,
https://developer.arm.com/documentation/ddi0301/h/unaligned-and-mixed-endian-data-access-support/mixed-endian-access-support/armv6-support-for-mixed-endian-data
In the previous version, changes are made unconditionally. But, these
should be restricted to target NetBSD.
I updated the patch:
http://www.netbsd.org/~rin/rpi_eb_gcc_20201123.patch
For (1), our code uses its own BE8_LINK_SPEC. But this is incomplete;
new CPUs are not supported. Therefore, I define ARM_BE32_IF_POSSIBLE
macro in netbsd-eabi.h and stop emitting --be8 flag for ARMv6 if this
macro is defined.
For (2), disable -munaligned-access for big-endian mode on ARMv6, if
ARM_BE32_IF_POSSIBLE macro is defined.
I also note that we don't need worry about ABI changes. We don't have
working earmv6{,hf}eb userland yet. At the moment, our kernel does not
support earmv6{,hf}eb, and their userland does not work on other ARM
subarchs; due to lack of ARMv6 instructions on ARMv5 and prior, and
due to lack of BE32 support on ARMv7 and later.
Thoughts?
Thanks,
rin
On 2020/11/16 7:53, Rin Okuyama wrote:
On 2020/11/16 6:28, matthew green wrote:nice work. i agree with your proposed changes in general.Thank you!Therefore, (1) configure GCC not to emit unaligned access for earmv6{,hf}eb. http://www.netbsd.org/~rin/rpi_eb_gcc_20201115.patchthis part doesn't seem right: - && arm_arch6 && (arm_arch_notm || arm_arch7)); + && arm_arch6 && ((arm_arch_notm && !BYTES_BIG_ENDIAN) || arm_arch7)); i would have expected "&& !BYTES_BIG_ENDIAN" to have been added to the "arm_arch6", not the "arm_arch_notm" section.This is not wrong; arm_arch6 && ((arm_arch_notm && !BYTES_BIG_ENDIAN) || arm_arch7) is equivalent to (arm_arch6 && arm_arch_notm && !BYTE_BIG_ENDIAN) || arm_arch7 This is confusing, but I prioritized the original form.since this is really a hardware issue, and this is a bug all GCC arm, not netbsd target, it would be nice if you attempted merging this upstream as well :)Unaligned access is possible for ARMv6 in BE8 big-endian mode, which seems to be used for OSes other than NetBSD. While it is not possible in BE32 big-endian mode for us. Hmm, I started thinking that the fix should be restricted to NetBSD target. But I don't know how to deal with this... FreeBSD uses SUBTARGET_OVERRIDE_INTERNAL_OPTIONS. But, at the moment when SUBTARGET_OVERRIDE_INTERNAL_OPTIONS is called, opts_set->x_unaligned_access is already modified by arm_option_override_internal(). Any ideas? Define new macro, e.g., SUBTARGET_OVERRIDE_UNALIGNED_ACCESS_OPTIONS in netbsd-eabi.h? Thanks, rin