Adding custom sections to default linker script
Jonas Maebe
jonas.maebe@elis.ugent.be
Thu Sep 3 08:55:00 GMT 2015
Erik Christiansen wrote on Mon, 31 Aug 2015:
> Ah, I missed the "custom compiler" context. In that case, maybe just
> tweak the internal linker scripts? They're generated from
> <eachtarget>.sc in the source, e.g. binutils-2.23/ld/scripttempl/ .
> Tweaking templates causes your customisations to be not only fully
> integral to the toolchain, for the specified targets, but also more
> customisable than a generic INSERT. (And very easy)
The problem with internalising the complete linker script is that these
often contain Linux distribution-specific library search paths. That's
the main reason why we want to augment rather than replace them. E.g.,
from a Scientific Linux 6.7 system (= RHEL 6.7):
SEARCH_DIR("/usr/x86_64-redhat-linux/lib64");
SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64");
SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/x86_64-redhat-linux/lib");
SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib");
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
We can't hardcode this for every (version of) every distribution, nor do
we want to make our compiler distribution-specific or make people
specify these search paths by hand. Right now, our compiler works on
pretty much any Linux system with binutils 2.16+ and a Linux kernel 2.20+.
On another note, I discovered a problem with the -T and INSERT: it
appears that if the linker response file contains an ENTRY() command, it
gets ignored in this case and the one from the default linker script
gets used. We need that for proper initialisation/finalisation of
dynamic libraries :/
Jonas
More information about the Binutils
mailing list