possible bug in coffcode.h

Guy.McCarthy@microchip.com Guy.McCarthy@microchip.com
Wed Mar 13 14:36:00 GMT 2002


Hello All,

There seems to be a bug in bfd/coffcode.h, in v2.12 and previous versions.

If you compile the following program on a generic COFF target:

[~]gcc -o try.exe -g try.c

objdump reports a corrupt output file:

[~]objdump -g try.exe

try.exe:     file format xxxx

objdump: 11: .bf without preceding function

The problem seems to be with line 4455 in coffcode.h:

                dst->symbol.flags = BSF_WEAK;

This over-writes the BSF_NOT_AT_END | BSF_FUNCTION flags set at line 4404. 
Consequently, symbol _f2 gets moved when it shouldn't.

To correct the problem, change line 4455 to OR in the BSF_WEAK flag.

[contents of file try.c]
int main()
{
  volatile int k;
  k = f2(k);
}

int __attribute__((__weak__)) f2(int n)
{
  return 2 * n;
}

Regards,

Guy McCarthy
Microchip Technology, Inc



More information about the Binutils mailing list