1

What is the difference between these errors in GNU Binutils ld ?

  • undefined reference
  • undefined symbol

I have a good understanding of undefined reference: This occurs for example when the loader cannot find the implementation of a function. I am curious to know the cause of undefined symbol.

Adam
  • 67
  • 1
  • 8

1 Answers1

3

e.g. when you do some arithmetic in your linkerscript using a symbol which is not yet defined. In my situation, this is mostly due to typo's.

_syma = 1 ;
_syna += 1 ;
/* error: undefined symbol `_syna' referenced in expression */

or

_syma = 1 ;
_symb = _syna + 1 ;
/* error: undefined symbol `_syna' referenced in expression */

When you assign an output section to an undefined symbol, you get another error:

_syma = 1 ;
.text _syna :
/* error: non constant or forward reference address expression for section .text */
{
  *(.text) ;
}
parvus
  • 5,706
  • 6
  • 36
  • 62