Linker script using INSERT AFTER
Jan Blunck
jblunck@suse.de
Mon Oct 26 17:07:00 GMT 2009
I'm trying to come up with a clever linker scripts, actually as an so-file,
that is inserting some symbols if they are not provided by the objects being
linked. Therefore I tried to use INSERT AFTER like this:
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /usr/lib64/libust.so.0 /usr/lib64/libust-initializer.o )
SECTIONS
{
PROVIDE_HIDDEN(__start___markers = .);
__markers : { *(__markers) }
PROVIDE_HIDDEN(__stop___markers = .);
PROVIDE_HIDDEN(__start___tracepoints = .);
__tracepoints : { *(__tracepoints) }
PROVIDE_HIDDEN(__stop___tracepoints = .);
}
INSERT AFTER .data;
I get this error during linking:
/usr/lib64/gcc/x86_64-suse-linux/4.4/../../../../x86_64-suse-linux/bin/ld:
warning: /usr/lib64/gcc/x86_64-suse-linux/4.4/../../../../lib64/libust.so
contains output sections; did you forget -T?
/usr/lib64/gcc/x86_64-suse-linux/4.4/../../../../x86_64-suse-linux/bin/ld:
.data not found for insert
collect2: ld returned 1 exit status
make: *** [basic] Error 1
Anyway, since I though that it isn't necessary to add an empty section (if
__start___markers isnt' there I know that the section will be empty anyway) I
thought that I can live with the following:
SECTIONS
{
PROVIDE_HIDDEN(__start___markers = .);
PROVIDE_HIDDEN(__stop___markers = .);
PROVIDE_HIDDEN(__start___tracepoints = .);
PROVIDE_HIDDEN(__stop___tracepoints = .);
}
INSERT AFTER .data;
That actually works, but it seems to override the hidden symbol that comes
with on of the objects to link with. Somehow I think this isn't correct due to
the description of PROVIDE_HIDDEN().
Any hints what I'm doing wrong?
Regards,
Jan
--
Jan Blunck <jblunck@suse.de>
More information about the Binutils
mailing list