-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi-segment data/bss #632
Comments
Thanks for pointing this out. Unfortunately the current linker script and startup code seems to be misaligned. We have:
Hence we would need to change 1 and 2 to use word count, or only 3 to use byte count. Changes to 3 affect all users, i.e. switching between releases would need to be reflected in the linker script of the project. On the other hand changing 1 and 2 would change startup behavior of legacy components. |
I think. breaking compatibility of c-language part is a less nervous solution. And add to template link scripts second tables set with data conforms to fixed c-language functions. |
Hi @ua1arn, I read your suggestion that way: As a consequence, i.e. to keep assembly and C startup variants in sync, we need to update the assembly startup routines, accordingly. In fact this might be the least disturbing fix. Both, the linker script and the assembly startup module, are configuration templates. I.e. both are intended to be used by copy. A change to these files would not affect any project unless a user updates both files, actively. Does that makes sense to you? Cheers, |
No. I propose change __cmsis_start implementation . Change names and types of used tables. |
This modification affects only project uses c-language startup. Other work without problems |
@ua1arn, if we change |
Confusion and error at link phase but not silent hung at startup. Add "four" modified tables to template link scripts, Not remove old tables. |
Where do you see the chance of a silent hung up at startup? Sure, currently having this bug is ugly. But fixing it in the linker script properly should fix everything. Simply adding new tables would force any user to adopt the template depending on the startup code in use. There would not be a meaningful default that just works out of the box anymore. That looks even worse to me. |
I propose add TWO set of tables in template link scripts and CHANGE cmsis_start implementation for use new tables. |
@ua1arn, sorry, I think we are not yet on the same page. I have five scenarios in mind I'd like to check:
The ideal case would be if all scenarios run seamlessly. Where of course scenario 2 (*) is affected by the bug. Hence this user would need to apply the workaround (i.e. update the linker script) today and update the linker script again during update. In summary this bug seems to be kind a nasty. |
As a fact: no one can use |
@ua1arn, sure. Current situation is (*) |
I insist: overwriting of |
Hi @ua1arn, after having multiple discussions we decided to concentrate on fixing the issue as local as possible. In this case the problem came from misinterpreting the section length as word count instead of byte count. Keeping the tables as they are since decades, i.e. not touching the linker scripts, and fixing
should do the job. This brings the C implementation back in sync with the assembly version. I admit that moving the division by 4 to the linker script would save some instructions at run time, at least for the C version. The price is changing the linker script as well. And to keep assembly and C version in sync we would need to think about the assembly implementation. Keeping a double set of tables in the linker script by default would outweigh the optimization. I hope this decision makes sense to you and solves the problem, ultimately. Thanks again for pointing out this issue. Cheers, |
I think, change C interpretation may rise bug in project already uses |
Just run into this issue. I vote for linker script update. Division by 4 in runtime makes no sense. |
I wouldn't sweat the "division by 4" - it's well within a compiler's loop optimisation capabilities to eliminate it - it effectively cancels out with the internal "multiplications by 4" occurring for the However, all the pointer stuff is potentially going to cause a headache, including potentially eliminating that optimisation. In particular, the compiler has to assume that the It would be beneficial to load the pTable entry into local variables prior to the inner loop. (Just loading Doing that should save far more than added by putting that (Addendum - yes, |
Further addendum - you may as well just use If you did have a reason to not use them, you may in fact want to take more care to prevent the compiler from turning your manual code into those calls itself. GCC can spot that you're doing a copy loop and put in a call to memcpy/memset instead. I've seen people add In your case, the potential aliasing between |
Hi @kjbracey-arm, I had a version using Do you agree that adding the division by 4 to the loops is the least intrusive fix? Thanks, |
I am agree with any progress in this issue. |
About "intrusive fix" i'm saying before. |
It may be worth commenting that division by 4 is only valid if
I agree. The comment by kjbracey-arm is the opposite of what happens in reality. On my machine, the minimum loop code is achieved by using an intermediate
which results in inner loop asm (compiled with gcc 7.2.1 and -O2 -mthumb -mcpu=cortex-m0) of:
which is as good as it gets! Conor. |
Hi all, can you review the proposed fix, please? Cheers, |
Divide by 4 in the linker file and multiply by 4 in the assembly files. Seem fine to me. |
In template link scripts (Device_Template_Vendor\Vendor\Device\Source\GCC\startup_Device.S as example) lengths of filled/copied areas calculated as bytes:
But, actual __cmsis_start implementation assume these values as number of uint32_t elements,
I propouse change all template and ARM-produced startup files like this:
The text was updated successfully, but these errors were encountered: