Jump to content

Linker Removing Too Much Code

Recommended Posts

Bug description:

The BoostC documentation says that "_asm" will remove dead code but "asm" will not (page 64). This does not appear to be the case - dead code is being removed with "asm" also. This is a problem because the "dead" code is actually needed.


Example code:

#include <system.h>

unsigned char var1;

inline void func(void)
 asm //use asm block to prevent dead code removal
  	  addwf _pcl, F;
	 bcf _var1, 1;
	 goto return2caller;
	 goto return2caller;
	 bcf _var1, 2;
	 goto return2caller;
	 movlw 0x11;
;		goto update; //problem line
	 bcf _var1, 3;
	 goto return2caller;
	 bcf _var1, 4;
	 goto return2caller;
	 movwf _var1;

void main(void)
 asm movf _var1, W;


With the "problem line" commented out, the example code compiles and links correctly (no code is removed). However if the "problem line" is not commented out, the code will still compile but the linker will report the following error:

Internal Error: Unable to resolve label ID:268438699 - 0x10000CAB
BoostLink Optimizing Linker Version 7.10


It looks like it might have removed the section of code containing the "update" label, even though this was contained within the asm block (or maybe the linker is doing something else instead).



Expected behavior:

Linker should leave in the "update" label and "movwf", and not report an error. In either case, no "dead" code should be removed. Placing "#pragma OPTIMIZE "0"" ahead of func1 does not help either.


Is the problem 100% reproduceable:






Compiler version:



Target device:

PIC16F1827, etc.



Windows XP



Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...