I realized that I didn't want Level 9 (Common Block Subroutine Packing) optimizations performed on my code. Now, going back to Level 8 optimizations, I get IMPROPER FIXUP errors in my assembly startup code. What's the deal?
Now, going back to Level 8 optimizations, I get IMPROPER FIXUP errors in my assembly startup code. Hmmmm... The C Compiler doesn't assemble the startup code. The assembler does that. And, optimizer level 9 or 8 on the compiler have no effect on the assembler. What are the exact error messages you get from the assembler? Keil Support
They are actually linker errors. The linker is complaining about my startup assembly file. I get 5 IMPROPER FIXUP errors; they only differ in the OFFSET parameter. Here is the first error: *** ERROR L121: IMPROPER FIXUP MODULE: .\Simulator\Object\startup.obj (?C_STARTUP) SEGMENT: ?C_C51STARTUP OFFSET: 0028 Once again, if I change my compiler option back to level 9, then this error goes away.
OK, here'a solution to try. 1. Remove the STARTUP.A51 file from your project. 2. Compile and link your project. If you get no errors, then the STARTUP you have is being assembled incorrectly OR you have made changes to it that generate this problem. Copy the startup code from the \keil\c51\lib directory and include it in your project WITH NO CHANGES. Rebuild and see what happens then. If you get errors without the startup code, then there is a problem with the default startup code. Let us know if this happens. Keil Support
I get no errors with the default startup. Of course, however, I need my own startup. My startup assembles without errors. Do you need me to send you my code?
Yes, I would appreciate that. Dale
OK, Copy the STARTUP.A51 from the lib directory into your project directory and include it in your project. Do not change anything in this file. Build the project and check to see if there are any linker errors. If there are none, then the startup code is not corrupted. Modify the startup code 1 line at a time. Build and link your project this way step by step. When you modify a line and then get the linker error, you know what caused the Improper Fixup error message. Usually, that error message is caused when you try to use an address that is not valid in a memory space. For example trying to access address 0x1234 in the IDATA area (since the maximum IDATA address is 0xFF). Keil Support
A couple of things: 1) Why would going to optimization level 9, fix the IMPROPER FIXUP problem? 2) When I take my startup.a51 and only include one other C file (with my main() function, I do not get any IMPROPER FIXUP linker errors. 3) What is an email address that I can send my code to? The code is fairly simple.
1) Why would going to optimization level 9, fix the IMPROPER FIXUP problem? No idea. 2) When I take my startup.a51 and only include one other C file (with my main() function, I do not get any IMPROPER FIXUP linker errors. OK. When you do get improper fixup errors, the linker will tell you where the problem exists. Have you looked at that line of your source code to see what the problem could be? 3) What is an email address that I can send my code to? The code is fairly simple. support@keil.com Keil Support
For those following this thread, the Keil Support Team came up with this answer: The problem you are seeing is due to the ACALLs in your startup code. The improper fixup is telling you that the label the ACALLs are referencing is not located in the same 2K page as the ACALLs themselves. There are 2 solutions to this problem: 1. USE LCALLs. 2. Change the declaration of the startup segment so that it starts at the beginning of a 2K boundary. Change the declaration for that segment to the following and your program will link with no errors: ?C_C51STARTUP SEGMENT CODE INBLOCK I assume that when Code Optimization Level 9 was being used, all my startup code happened to fit in the same 2K block, and when level 8 was used, some of my 'bloated' C code got injected in the startup space blowing it up to greater than 2K for the ACALL.