Jump to content
teejaydub

Linker Internal Error Message Lacks Information

Recommended Posts

I frequently get the following message from the linker:

 

Linker Internal Error: Can't find label

 

I'm afraid I can't give you source code to reproduce it without an NDA, and I haven't been able to narrow down the symptoms to a small section of code - in fact it may correlate with large blocks of code.

 

So of course diagnosis on your end may be hard. But if you can add more information to that error message, specifically what label isn't found, it would at least help figure out what elicits the bug.

Share this post


Link to post
Share on other sites

teejaydub,

I frequently get the following message from the linker:

 

Linker Internal Error: Can't find label

 

I'm afraid I can't give you source code to reproduce it without an NDA, and I haven't been able to narrow down the symptoms to a small section of code - in fact it may correlate with large blocks of code.

 

So of course diagnosis on your end may be hard.  But if you can add more information to that error message, specifically what label isn't found, it would at least help figure out what elicits the bug.

This is an instruction level error that is generated when linker is looking for a label in the opcode list.

 

Its will be almost impossible to find this without example code in some form.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Its will be almost impossible to find this without example code in some form.

 

I agree. I'm asking instead for a better error message that gives me something that might be helpful in dealing with the problem. Only you know what extra context info you have when that message is generated; maybe there's nothing helpful available, but if there is, I'd love to see it.

Share this post


Link to post
Share on other sites
Its will be almost impossible to find this without example code in some form.

 

I also have observed this problem several times. Recompiling everything did not work, but moving the code did work... When I have it again, would it be useful that I send the complete project?

 

Thanks,

 

Frederic

Share this post


Link to post
Share on other sites

FredericG

I also have observed this problem several times. Recompiling everything did not work, but moving the code did work...  When I have it again, would it be useful that I send the complete project?

Yes it would be extremely useful, please do so.

Without being able to reproduce a problem its almost impossible to fix it.

 

Regards

Dave

Share this post


Link to post
Share on other sites

I too 'randomly' get this error message.

 

Senario. projects contain 1 main source file and numerous includes.

Linking fails as shown below.

 

This has now happened to me on two projects. Once it started, the 'project' remains unbuildable, until....

The project that broke for me yesterday works today - but a new project is broken today.

 

Simply renaming the .c file and recompiling/relinking using the new (base)name, works.

-- Fredric, thanks very much for the "moving the code did work" tip.

Another tip: Inserting a blank line at the top of the source file may help.

 

.duanec.

Share this post


Link to post
Share on other sites

Frederic, this may or may not help...

You might try changing "?:" operators that are like this:

	expression ? value1 : value2

to something like this:

	(expression)!=0 ? value1 : value2

 

 

Dave,

Maybe the following will help you debug this.

Both these bugs ("Linker Internal Error" and "CompilerCrash") might relate to the ?: operator.

(Though the former bug also appears to depend on 'random' stuff like filename and line number).

 

----------------------------------------------------------------

 

BUG 1 of 2, "Linker Internal Error":

	...
typedef unsigned char   u8;
typedef unsigned int	u16;
...
u8 edU16(u8 r, u8 c, u8 charWidth, u16* p_num) { ... }
...
u8 edU1(u8 r, u8 c, u8* p_num) {	//$ TODO: move to a 'library'; replace w/ include
	u8 res;
	u16 num;
	num=*p_num;
	res=edU16(r,c,1,&num);
	*p_num=num ? 1 : 0;		 //// NOTE THIS LINE ////
	return res;
}
...

 

When I insert a (blank) line anywhere before the above noted line, the linker works.

Inserting a (blank) line after the noted line did not "fix" the linker problem.

"Optimisation level:1"

"Linker Internal Error: Can't find label"

 

Also changing the line to use the expression "num!=0" instead of reading "num" WORKS!!

NOTE: this same work-around also works for the "CompilerCrash" bug.

 

This may (or may not) be related to the following bug that CRASHES THE COMPILER, and also uses the "?:" operator.

 

I can email you a tarball if needed -- but the code is moderately ugly / contorted -- the 1k program

has something like 10 source files (lots of conditionals to address different chips, different

compilers, and different prototype boards and applications).

 

----------------------------------------------------------------

 

BUG 2 of 2, "CompilerCrash":

Compiling the following source CRASHES THE COMPILER with the windows' error dialog

"Error: Access violation at 0x004508B4 (tried to read from 0x00000010), program terminated."

	#include <system.h>
void aFunc(unsigned char c) { }
void main(void) {
	aFunc(		  1 ? '\x40' : '\x00'	 );  // fails
}

 

(yes, I know the above source is pretty 'goofy' looking -- I've removed all the context to find the 'minimum' problem.)

 

Note: changing "1 ? ..." to "1!=0 ? ..." again "fixes" the problem.

 

Note: As far as I could find, this bug required 3 things to happen:

1 ?: operator with a CONSTANT firstOperand ---- i.e. it is ok if lhs is a variable

2 ?: operator with a constant NUMERIC firstOperand ---- i.e. it is ok if lhs is a boolean expression

3 ?: operator used as an argument to a function

---- i.e. charVariable = 1 ? '\x40' : '\x00'; // works

---- whereas functionOfChar ( 1 ? '\x40' : '\x00' ); // crashes

 

----------------------------------------------------------------

Edited by dfcampbell

Share this post


Link to post
Share on other sites

i can say that i have no issues with that operator, which i use liberally.

Altho in a slight different form ... i like brackets ;)

(i>12)?(i=0):(i++);

Share this post


Link to post
Share on other sites

dfcampbell,

 

BUG 1 of 2, "Linker Internal Error":

	...
typedef unsigned char   u8;
typedef unsigned int	u16;
...
u8 edU16(u8 r, u8 c, u8 charWidth, u16* p_num) { ... }
...
u8 edU1(u8 r, u8 c, u8* p_num) {	//$ TODO: move to a 'library'; replace w/ include
	u8 res;
	u16 num;
	num=*p_num;
	res=edU16(r,c,1,&num);
	*p_num=num ? 1 : 0;		 //// NOTE THIS LINE ////
	return res;
}
...

 

When I insert a (blank) line anywhere before the above noted line, the linker works.

Inserting a (blank) line after the noted line did not "fix" the linker problem.

"Optimisation level:1"

"Linker Internal Error: Can't find label"

 

Also changing the line to use the expression "num!=0" instead of reading "num" WORKS!!

NOTE: this same work-around also works for the "CompilerCrash" bug.

 

This may (or may not) be related to the following bug that CRASHES THE COMPILER, and also uses the "?:" operator.

 

I can email you a tarball if needed -- but the code is moderately ugly / contorted -- the 1k program

has something like 10 source files (lots of conditionals to address different chips, different

compilers, and different prototype boards and applications).

 

----------------------------------------------------------------

 

BUG 2 of 2, "CompilerCrash":

Compiling the following source CRASHES THE COMPILER with the windows' error dialog

"Error: Access violation at 0x004508B4 (tried to read from 0x00000010), program terminated."

	#include <system.h>
void aFunc(unsigned char c) { }
void main(void) {
	aFunc(		  1 ? '\x40' : '\x00'	 );  // fails
}

 

(yes, I know the above source is pretty 'goofy' looking -- I've removed all the context to find the 'minimum' problem.)

 

Note: changing "1 ? ..." to "1!=0 ? ..." again "fixes" the problem.

 

Note: As far as I could find, this bug required 3 things to happen:

1 ?: operator with a CONSTANT firstOperand ---- i.e. it is ok if lhs is a variable

2 ?: operator with a constant NUMERIC firstOperand ---- i.e. it is ok if lhs is a boolean expression

3 ?: operator used as an argument to a function

---- i.e. charVariable = 1 ? '\x40' : '\x00'; // works

---- whereas functionOfChar ( 1 ? '\x40' : '\x00' ); // crashes

 

----------------------------------------------------------------

Please send projects demonstrating these problems to support@sourceboost.com, that will be a great help.

 

Regards

Dave

Share this post


Link to post
Share on other sites

FredericG,

I had it again. Dave, I have sent a tar of the project.

Recompiling did not work. Removing some old useless code did help

Which version of the compiler do you use?

Your code compiles fine when V6.83 is used.

 

Regards

Dave

Share this post


Link to post
Share on other sites
FredericG,
I had it again. Dave, I have sent a tar of the project.

Recompiling did not work. Removing some old useless code did help

Which version of the compiler do you use?

Your code compiles fine when V6.83 is used.

 

Regards

Dave

I was still using 6.6 as 6.7 made my code bigger (pointer operations I think)

I now switched to 6.83 and it works fine.

 

Frederic

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
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.

Loading...

×