automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dependence on object files listed in link script


From: Tzu-Chien Chiu
Subject: Re: Dependence on object files listed in link script
Date: Thu, 5 Oct 2006 21:37:12 +0800

2006/10/4, Stepan Kasal <address@hidden>:
On Wed, Oct 04, 2006 at 11:59:40AM +0800, Tzu-Chien Chiu wrote:
> bar_LDADD = @top_builddir@/xyz.la
> bar_DEPENDENCIES = $(bar_LDADD) @many_objs@

a few nits first:  all AC_SUBSTed variables are available as make
variables, so you can use $(top_builddir) and $(many_objs).
Actually, this is the prefferred way.

When @xxx@ and $(xxx) will make difference, please?


> When the number of object files grows, it's difficult to maintain
> these files. Better approach anyone, please?

I can see only one remaining problem: both linkscript.ld and
configure.ac contain the same long list of objects.
Then you can select one file, which will have the list, and the other
ones will be generated.

First solution:
linkscript.ld would be the primary source, and configure.ac would do
this:
many_objs=`sed -n '/^SECTIONS/,/^}/{
  s|.*{ *\(.*\)\.o *}.*|$(top_builddir)/\1.lo|p
}' $srcdir/linkscript.ld |tr '\n' ' '`

In my case, no. My link script is generated by `configure` because a
few SEARCH_DIR (actually quite a few) must be inserted by autotools in
order that the linker can fine them. The syntax of section placement
doesn't allow to prefix the path to name of object files. Without
SEARCH_DIR, I have to add these search paths to the command line
parameters for the linker anyway.


Another solution:
linkscript.ld might be generated by a rule in Makefile.
Actyally, the variable many_objs could be defined directly in
Makefile.am, too.  Something like this:
many_objs = foo.lo bar.lo ..

linkscript.ld: Makefile
        ( \
        echo "SECTIONS {"; \
        for obj in $(many_objs:.lo=.o); do \
          echo "  .a { $$obj }"; \
        echo "}"; \
        ) >$@

Or you can write an awk or ruby script to generate linkscript.ld from
a list of object files passed as parameters.

I think it works for the other projects, but unfortunately not for
mine. The object files from different directories are placed into
three to four sections, without any naming rules.

The fact that LD doesn't consider the object files in the link script
to be part of the dependence is a *design* or a *bug*?



I'm porting a large piece of embedded system software. Porting in some
sense is very a different thing than developing a new project (at
least to me). You are not the part of the original team who developed
it, and there are millions of lines of code you might never read even
after the project ends. Not to say it's poor (if any) documented.
That's why I preferred not to alter the directories structure, file
names, even the architecture unless it has to. The special section
placement is of course a necessary exception.

--
Tzu-Chien Chiu - SMedia Technology Corp.
URL: http://www.csie.nctu.edu.tw/~jwchiu/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]