aarch64: end the .aros.init directive so its attributes survive - #1044
aarch64: end the .aros.init directive so its attributes survive#1044metaneutrons wants to merge 1 commit into
Conversation
092d367 to
b44a4a8
Compare
.aros.init holds two things: the entry point, which has to be
executable, and a pair of stack pointers, which do not. The section is
therefore declared twice - once as "ax" by the inline asm carrying
start:, and once through a section attribute on the pointers - and the
second declaration must not carry attributes of its own.
TARGET_SECTION_COMMENT exists for exactly that. It ends the directive, so
whatever flags the compiler appends become a comment and the section
keeps what the entry point asked for. It reaches this file from the
mmakefile as -DTARGET_SECTION_COMMENT="$(AROS_SECTION_COMMENT)", and
arrives empty, so the flags come through, the second declaration says
"aw" where the first said "ax", and the assembler refuses it:
Error: changed section attributes for .aros.init
Why it arrives empty is worth stating precisely, because it decides
where the real fix goes. The value is not configure.in's; it belongs to
config/features, which does probe for it and picks "#", "@" or falls back
to "//". The probe never runs here, because the whole block sits inside
if test "$AROS_TARGET_CPU" = "arm"; then
so every target that is not arm skips it and gets the empty string. A
riscv build on this machine shows the same thing from the other side:
gen/config/compiler.cfg has AROS_SECTION_COMMENT empty and the features
log has no "comment style" line at all.
There is a second fault in the same probe, and it is why widening that
test alone would not be enough. Its test program assembles
ldr sp, section_ptr
which is an ARM instruction, so on any other target both the "#" and the
"@" attempt fail on the instruction rather than on the section
attribute, and the probe lands on its "//" fallback whatever the
assembler would actually accept. arm-native's own kernel_startup.c
records that "//" is not a comment for clang's integrated assembler.
Doing this properly therefore means widening the CPU test and making the
test program target-neutral, so the assembler decides.
That is a change across targets I cannot test, so it is not attempted
here. This defines the macro locally, exactly as
arch/riscv-native/sifive_u already does in its own kernel_startup.c -
and sifive_u has a third variant of the same workaround in
boot/mmakefile.src, plus the mmakefile -D commented out in
kernel/mmakefile.src, which is the clearest evidence that the configure
value has been unusable for some time. Happy to follow up with the
config/features fix if there is appetite, or to have this rejected in
favour of doing that first.
Only visible now because it takes a strict enough assembler to reject it
and a toolchain new enough to build at all on a current host.
Tested on darwin-aarch64 building raspi-aarch64.
b44a4a8 to
f470b3f
Compare
|
Thanks for writing this up so carefully, and for flagging it as a workaround rather than presenting it as the fix. The observations are right: the probe is gated to arm at I think the conclusion drawn from that is off in two ways, and both point at the probe rather than at the arch sources. arm is not the working case either. Running the probe's own test programs through Both real candidates are rejected for reasons unrelated to comment syntax, so the probe falls through to its untested two-slash fallback. That is the value armhf ative/kernel/kernel_startup.c` alreadyrecords that it is not a comment for clang's integrated assembler. My invocation did not carry the configure-time flags, so the link error may differ in a reaure does not depend on flags. **The probe cannot tell a working comment fr only checks that the program compiles andlinks. On x86_64 with GNU as every candidate passes, but the objects differ: The at-sign and two-slash forms comment nothing out. They create a second section named after the suffix, so the On the local define: which spelling works is toolchain dependent. With the aarch64 clang 11 in my tree the polarity inverts: So the value copied from riscv produces a separate section under that assembler while working under GNU as. Yours may There is also a structural concern. An A probe-side fix looks smaller than it might appear, and needs no hardware testing because it can validate itself:
|
.aros.initholds two things: the entry point, which has to be executable, and a pair of stack pointers, which do not. The section is therefore declared twice — once as"ax"by the inline asm carryingstart:, and once through a section attribute on the pointers — and the second declaration must not carry attributes of its own.TARGET_SECTION_COMMENTexists for exactly that: it ends the directive, so whatever flags the compiler appends become a comment and the section keeps what the entry point asked for. It reaches this file from the mmakefile asand arrives empty. The compiler's flags come through, the second declaration says
"aw"where the first said"ax", and the assembler refuses it:Why it arrives empty
Worth stating precisely, because it decides where the real fix goes — and it is not
configure.in. The value belongs toconfig/features, which does probe for it and picks"#","@", or falls back to"//". The probe never runs here, because the whole block sits insideso every target that is not arm skips it and gets the empty string. A riscv build shows the same from the other side:
gen/config/compiler.cfghasAROS_SECTION_COMMENTempty and the features log has no "comment style" line at all.And widening that test alone would not be enough
There is a second fault in the same probe. Its test program assembles
which is an ARM instruction. On any other target both the
"#"and the"@"attempt fail on the instruction rather than on the section attribute, so the probe lands on its"//"fallback whatever the assembler would actually accept — andarch/arm-native/kernel/kernel_startup.calready records that"//"is not a comment for clang's integrated assembler.Doing this properly therefore means widening the CPU test and making the test program target-neutral, so the assembler decides. That is a change across targets I cannot test, so it is deliberately not attempted here.
This is a workaround
Defined locally, exactly as
arch/riscv-native/sifive_ualready does in its ownkernel_startup.c. sifive_u also has a third variant inboot/mmakefile.src, which passes the-Ddirectly, and the mmakefile line inkernel/mmakefile.srcis commented out — which is the clearest evidence that the configure value has been unusable for some time.I am happy to be told to do it properly instead of this. If the preference is a
config/featuresfix, say so and I will close this in favour of one — it just needs someone who can test the other targets.Why now
It takes a strict enough assembler to reject this and a toolchain new enough to build at all on a current host. Neither condition held for the aarch64 target until recently.
Testing
Tested on
darwin-aarch64buildingraspi-aarch64. Not run on hardware, hence draft.