Page 1 of 1

Avoiding segfaults in ld

Posted: Thu Sep 19, 2013 5:01 pm
by xobs
I'm using the version of ld from Debian's armhf "Wheezy" distribution ("GNU ld (GNU Binutils for Debian) 2.22"), and occasionally I would experience segfaults in ld when linking. I was able to track down a workaround after building a debug version of ld, but I'm still not sure why it's segfaulting in the first place.

I'm using ChibiOS with an STM32F101x8, so I've needed to create the ld script myself. Still, the following might be useful to anyone else experiencing random segfaults.

What solved my problem was adding the following to the SECTIONS definition:

Code: Select all

.rel.plt : { . = .; } > flash


I noticed that libbfd was looking for the section ".rel.plt" and was segfaulting on a NULL pointer when it couldn't find one in the hash table. My workaround is to create an "empty" entry in the hash table.

I don't know the scope of this problem, but here's the workaround in case anyone else is experiencing the same.