This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

About error L138 caused by jump target out of range

I used keil c to compile my program. When I deleted a unused function, it procuce the ERROR L138: CODE GENERATION: PROBLEM WHEN PROCESSING INSTRUCTIONS
CAUSE: JUMP TARGET OUT OF RANGE
ADDRESS: 047E6H
But when I didn't delete the function, compile successfully. Who can tell me the reason? I am sure the program didn't use the function.

Parents
  • I've run across a similar bug a couple of times in 7.50a. It seems to be related to the dead code removal, in conjunction with linker common code optimizations. The linker will only partially remove unused code. A routine that isn't called will be left behind for some reason; that routine calls a ?L?COMxxx function that has been created by the optimizer and (properly) removed.

    The linker generates a jump target out of range error (as opposed to, say, unresolved external) when this happens. The target is the ?L?COMxxx stub, which makes it fun to debug, as the only way to find the address in the error is to look in the .cod file. The missing code doesn't correspond directly to source, after all.

    I've seen this twice, in two separate projects. We've tried to put together the proverbial small project that demonstrates the problem for tech support, but haven't managed to produce the problem on a small scale. (The bug might only show up in complex projects, of course.)

Reply
  • I've run across a similar bug a couple of times in 7.50a. It seems to be related to the dead code removal, in conjunction with linker common code optimizations. The linker will only partially remove unused code. A routine that isn't called will be left behind for some reason; that routine calls a ?L?COMxxx function that has been created by the optimizer and (properly) removed.

    The linker generates a jump target out of range error (as opposed to, say, unresolved external) when this happens. The target is the ?L?COMxxx stub, which makes it fun to debug, as the only way to find the address in the error is to look in the .cod file. The missing code doesn't correspond directly to source, after all.

    I've seen this twice, in two separate projects. We've tried to put together the proverbial small project that demonstrates the problem for tech support, but haven't managed to produce the problem on a small scale. (The bug might only show up in complex projects, of course.)

Children