Ticket #534 (Fixed)Wed Nov 10 22:01:49 UTC 2021
Link 5.38: AIF appears to be laid out incorrectly when object files with 32-byte alignment are included
Reported by: | Stuart Swales (8827) | Severity: | Normal |
Part: | RISC OS: C/C++ toolchain | Release: | |
Milestone: | Status | Fixed |
Details by Stuart Swales (8827):
Feeling brave, I used the ALIGN=5 directive on a couple of CODE AREAs in order to I-cache line align just a few time-critical functions (my VFP basic operators) in images which are linked with my softpcs library. These AREAs are named so as not to give alignment clash errors with C$$Code AREAs etc.
Looking at the linker map & symbols all seemed good, with those areas appearing to be aligned correctly, and many library test programs worked OK.
However, for a couple of these test programs, it can be seen that the contents of other RO DATA AREAs have been displaced further upwards in memory than they appear in the linker map (possibly by the amount of memory used to align those CODE AREAs), such that the test program’s initialised globals are not what they should be and things go downhill very quickly. I don’t even have to run these programs to see this, just load the AIFs into memory.
I will try to come up with a small package to demonstrate.
Changelog:
Modified by Stuart Swales (8827) Wed, November 10 2021 - 22:33:54 GMT
- Attachment added: link-align.zip
Try building the attached set of files with the Build script. Both the _dadd and _deq object files contain ALIGN=5 which seems necessary to provoke this. The foo and bar global variables are displaced relative to their symbols, so the values printed are wrong.
Modified by Sprow (202) Fri, August 26 2022 - 17:54:09 GMT
FWIW trying your example with link 5.06 (the oldest cruftiest version I could find from Acorn C 5) also produces a duff binary with the reference to foo & bar being 2 words off the end of the image. So this is a longstanding oddity – link 5.06 is from 11-Jan-1995!
Modified by Stuart Swales (8827) Mon, March 06 2023 - 15:29:08 GMT
- Status changed from Open to Fixed
Can confirm this is fixed in Link 5.39 (DDE31b). Thanks!