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, Daniel Jacobowitz wrote:

> On Tue, Oct 27, 2009 at 10:23:43AM +0100, Jan Blunck wrote:
> > On Mon, Oct 26, Daniel Jacobowitz wrote:
> > 
> > > On Tue, Oct 27, 2009 at 09:56:34AM +1030, Alan Modra wrote:
> > > > > 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().
> > > > 
> > > > PROVIDE and PROVIDE_HIDDEN should only provide definitions for
> > > > undefined or common symbols.  Perhaps you have one of the latter?
> > > 
> > > Is the symbol being overridden really in one of the input files?  Or
> > > is it linker created from a section named "__markers"?  Maybe the
> > > section symbols are being generated by ld after PROVIDE_HIDDEN is
> > > processed.
> > 
> > You are right, it is a symbol that is linker generated because it finds the
> > section named __markers.
> 
> In that case, you may be able to fix this by explicitly placing
> __markers instead.
> 
> SECTIONS
> {
> 	PROVIDE_HIDDEN(__start___markers = .);
> 	*(__markers)
> 	PROVIDE_HIDDEN(__stop___markers = .);
> 
> 	PROVIDE_HIDDEN(__start___tracepoints = .);
> 	*(__tracepoints)
> 	PROVIDE_HIDDEN(__stop___tracepoints = .);
> }
> 

Right. I tried that as well. Given the fact that the INSERT does not work as I
expected, this puts both sections at the very beginning which is a problem if
they are not empty (actually I haven't tried it with both sections empty, but
if they contain marker/tracepoint data the resulting binary doesn't start).

Therefore what I do now is pretty easy: the symbols are used to compute the
size of the section and read its contents. Therefore I use a weak and hidden
symbol reference now that lets the symbol to be zero if its undefined. Works
pretty well as long as zero minus zero equals zero ;)

Thanks for the help,
	Jan

-- 
Jan Blunck <jblunck@suse.de>


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