GCC SNAFU

Show is not over yetI study microprocessor architectures for fun. One of the steps necessary to studying microprocessors is to have the necessary compilers to compile software for the microprocessor. The nature of the code generated reveals quite a lot of underlying detail about a microprocessor.

In order to compile software for another processor architecture, what is needed is a ‘cross-compiler’. Such a thing will allow a computer running on an Intel/AMD machine to compile software for other non-Intel/non-AMD processors (like the ARM processor that runs software for your mobile phone).

So, I have wasted the last few days trying to compile a number of cross-compilers for several microprocessor architectures. For some reason, they fail to compile and the failure is often due to a ‘buffer overflow’ error.

*** buffer overflow detected ***: mb-ar terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0x40128558]
/lib/tls/i686/cmov/libc.so.6[0x40126680]
/lib/tls/i686/cmov/libc.so.6[0x40125d68]
/lib/tls/i686/cmov/libc.so.6(_IO_default_xsputn+0xc8)[0x4009ba18]
/lib/tls/i686/cmov/libc.so.6(_IO_padn+0xed)[0x4008ee0d]
/lib/tls/i686/cmov/libc.so.6(_IO_vfprintf+0x27cf)[0x4007015f]
/lib/tls/i686/cmov/libc.so.6(__vsprintf_chk+0xa7)[0x40125e17]
/lib/tls/i686/cmov/libc.so.6(__sprintf_chk+0x2d)[0x40125d5d]
mb-ar[0x8050f52]
mb-ar[0x804f10b]
mb-ar[0x8051c40]
mb-ar[0x8058fc8]
mb-ar[0x804ba65]
mb-ar[0x804c7a0]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0x40044685]
mb-ar[0x8049a61]

Turns out, that the problem is due to a new feature introduced in the GCC compiler used in Ubuntu 8.10. It checks things during compilation to prevent potential problems when running the software. The simplest fix was to down-grade the GCC compiler on the system, which did the trick.

The reason that it took me so long to spot this problem was because, compiling cross-compilers has always been a tricky issue. It is sensitive to the combination of tools and versions selected, as well as the target and host architectures. So, I didn’t realise that something was amiss until something that should have worked right out of the box, did not.

So, it wasn’t a problem on my end at all. I guess that I’ll have to try to compile the cross compilers again. I’m trying to compile cross-compilers for the MIPS and M68K architectures (in addition to the one above). If it all works, I’ll be terribly happy.

Published by

Shawn Tan

Chip Doctor, Chartered/Professional Engineer, Entrepreneur, Law Graduate.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s