This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linker script using INSERT AFTER


On Tue, Oct 27, 2009 at 10:12:56AM +0100, Jan Blunck wrote:
> On Tue, Oct 27, Alan Modra wrote:
> > The reason for the error is due to the order of script parsing.  -T
> > scripts are parsed before the default linker script, and files that
> > are found to be scripts when opening input files are parsed later.  So
> > your script is placed after the default script in the linker's
> > internal representation of script statements.  As the ld info doc
> > says, INSERT "inserts all prior linker script statements after (or
> > before) output_section".  In your case, "all prior statements" is the
> > entirety of the default script plus your script.  The linker can't
> > find a ".data" statement outside of this set.
> 
> Now I'm confused. I thought that this is exactly how it should work. First use
> the default linker script and after that augment it by inserting another
> section. I thought it is searching for .data in the statements that it already
> found, which includes the default linker script where .data should be defined.

ld doesn't track boundaries between one linker script and another.  So
.data in the default script is part of the block of statements that ld
will try to move when it processes the INSERT.  You can't insert into
the block you are moving..

> If I understand you correctly there is no chance of adding another (empty)
> section in linker scripts that are found when opening input files? I don't
> care that much where this section gets added though.

Not easily, anyway.  INSERT really only works in a -T script.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]