I have a project that compiles to about 30KB, so it takes a while to load to my 8051. I'm trying to fix a small part, so I commented-out most of my main() routine. The linker now warns me and says it won't include the uncalled segments, (good,) but then it says I've run out of PDATA space for many of the functions that remain, (bad.) I'm using the Compact memory model. When I don't comment-out these function calls, the whole project links correctly. Is this strange behavior, or am I missing something obvious? Thanks.
Overlaying considers all the segments in the call tree. When you don't comment out any code, the linker can build a complete call tree for your program. And, overlay analysis includes all the segments (function data). When you comment out the code, the linker warns you about uncalled segments and tells you that they will not be considered for overlay analysis. Since the linker doesn't know who calls these functions it assumes that their data segments cannot be overlayed. And, you run out of memory faster. My suggestion would be to use #IFDEF to ifdef out the functions and the calls to them. This avoids this kind of problem. Note that there are LOTS of threads about this issue. Search by the error message in the forum and in the knowledgebase for other suggestions and tips. Jon
Not enought info to provide much help except DON'T USE COMPACT MODEL. Always start with small memory model and explictly assign structs, arrays and seldom used globals to XDATA. DON'T USE COMPACT MODEL. You can still place variables in PDATA but I suggest not. Where possible, place any const data such as title blocks, large prinf strings that will not change into CODE space. In Startup.a51 you assign the location of pdata. The default is address 0x00 for P2. Startup will then initialize P2 at reset but if you later nickle with P2 the system DOES NOT return P2 to the original address. It's up to the user to monitor P2. It's not worth the effort. Just use the small memory model and move the large data structers into XDATA and let the system use the DATA area for locals, etc. Works much better. As to the error message, it sounds as if there are errors that mask the pdata overrun. When you comment out sections of code the later errors are identified. That's just pure guessing on my part.