This is the mail archive of the binutils@sources.redhat.com 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: [ELF] symbol sets handling [2]


On 7 Feb 2003, Ian Lance Taylor wrote:

> Fabio Alemagna <falemagn@studenti.unina.it> writes:
>
> > Another thing I'd like to propose - but dunno if it's doable or not - is
> > to make the symbol sets "sortable" by appending to the section name a dot
> > and a priority number. That way one could use the SORT() ld constructor to
> > sort the sections and hence the symbols they contain, much like c++
> > constructors are handled.
>
> Where would the priority number come from?

>From the same place where the section's name comes from: the source file.

Right now putting a symbol in the set works like this:

#define _elf_set_element(set, symbol) \
   static const void *__elf_set_##set##_element_##symbol##__ \
    __attribute__ ((unused, section (#set))) = &(symbol)

I would add a new way to add symbols, which looked like thios:

#define _elf_set_element_pri(set, symbol, pri) \
  static const void *__elf_set_##set##_element_##symbol##__ \
    __attribute__ ((unused, section (#set "." #pri))) = &(symbol)


>  For that matter, what are
> you trying to sort?  Do you want to sort a collection of symbol set
> sections?  If so, why?

Yes, I want to do that, and the reason is that I do it right now, but with
the help of a post processor which automatically builds a ld script and
feeds it to ld. The reason for I want to have sortable symbol sets is that
there are many occasions in which this is needed, basically all
sistuations in which one needs to have a collection os symbols which have
to be processed in a certain order. The AROS libc, for example, has
initialization routines which need to be called upon program startup in a
well defined order, and need to be called on program exiting in the
opposite order, and the same goes for the list of libraries to open, which
need to be opened in a well defined order.

As said, I already do this with a postprocessing tool, however putting
this in ld itself would be a cleaner solution, given there's already
support for symbol sets.

> Or do you want to sort the symbols within a
> single symbol set section?  If so, changing the section name won't
> help.  I think you could do that by using a linker script which names
> the symbol set explicitly; admittedly that loses the main benefit of
> symbol sets, which is that they are defined automatically without
> linker script support, but do you really have that many symbol sets
> which need to be sorted?

There are already 5 cases I can think of: c++ constructors, c++
destructors, general constructors, general destructors, library
openiong/closing. However, who am I to say that later on there wo't be the
need for other sets? I certainly cannot change everytime the ld script,
specially because I cannot force the USER to change it, not to mention
that right now everything is handled automatically, and so it oughta be
handled automatically in the future too.

It'd be fine if someone of you told me how to do it via emulation script
just for my target, though. I tried to reproduce the effect of the SORT()
command applied to a pattern, however I'm not sure how to do it, and if it
can be done at all by the time that orphaned sections are handled...

Fabio Alemagna


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