Page 1 of 1
Linked Script Wildcards?
Posted: Tue Apr 14, 2009 10:12 am
by Creature
I have a (possibly) rather stupid question about linker scripts. I was wondering if there was a way to use wildcards in input files. Suppose I have a directory with 2 object files 'main.o' and 'print.o', is there anyway I could do something like:
or something similar? It's really a pain to add an object file each time I create a new source file. So I figured there had to be some way of doing it.
Thanks,
Creature
Re: Linked Script Wildcards?
Posted: Tue Apr 14, 2009 11:12 am
by frank
I know that you can use *.o on the command line. I'm not sure about within linker scripts, you will just have to try for yourself.
Re: Linked Script Wildcards?
Posted: Tue Apr 14, 2009 12:00 pm
by Combuster
Otherwise, there's still the shell thing, like:
cat link.ld.in > link.ld
find blabla | grep lala | sed hobo >> link.ld
Re: Linked Script Wildcards?
Posted: Wed Apr 15, 2009 6:33 am
by Solar
The behaviour is not documented in the LD manual, so I wouldn't rely on it even if it works...
Which begs the question, why would you want to include both files in the linker script, instead of the LD command line?
Re: Linked Script Wildcards?
Posted: Wed Apr 15, 2009 8:55 am
by Combuster
(stab at the darkness) djgpp, 255 char command line
Before I forget, did you look at the
Makefile tutorial, so to not miss out on the obvious?
Re: Linked Script Wildcards?
Posted: Wed Apr 15, 2009 9:24 am
by DeletedAccount
Hi,
It can be easily automated
. Recursively scan the directory and generate the file
. I can send you the code if interested .
Regards
Sandeep
Re: Linked Script Wildcards?
Posted: Wed Apr 15, 2009 9:32 am
by Creature
Solar wrote:The behaviour is not documented in the LD manual, so I wouldn't rely on it even if it works...
Which begs the question, why would you want to include both files in the linker script, instead of the LD command line?
I was giving an example, I don't really have 2 object files in my linker script, there are many more and it's a pain to add them to the command line either way. I'm amazed that they didn't implement something automated into the linker script.
I guess I could do what Shrek proposed, but no thanks for the application, I can write it myself
.
Thanks for your help
.
Re: Linked Script Wildcards?
Posted: Wed Apr 15, 2009 11:07 am
by DeletedAccount
Hi,
I was just recommending a quick fix , so that the 'process' is not getting affected
. I would advise you to meditate further on the questions of other posters as well
.
Regards
Shrek
Re: Linked Script Wildcards?
Posted: Wed Apr 15, 2009 12:08 pm
by Creature
Yes, I'll take a look at the potential solutions, thanks to all of you
.
Re: Linked Script Wildcards?
Posted: Thu Apr 16, 2009 1:54 am
by Solar
Creature wrote:I was giving an example, I don't really have 2 object files in my linker script, there are many more and it's a pain to add them to the command line either way. I'm amazed that they didn't implement something automated into the linker script.
Because this is the classic scenario for a Makefile using "find" to get the list of source (and object) files... try the
Makefile tutorial in the Wiki for a guide on how to do that.
I guess I could do what Shrek proposed, but no thanks for the application, I can write it myself
.
Toying with the linker script is the wrong solution for this (very valid) problem, IMHO.
Re: Linked Script Wildcards?
Posted: Thu Apr 16, 2009 2:17 am
by Creature
Well I had more of an idea to use the linker script without the input files and write some kind of application that grabs all the object files in the specified directory and adds them to the 'ld' command line one by one. Though tedious and possibly slow, it still does the trick. I was trying to stay away from makefiles (as I don't really know a lot about them). Guess it's time to see how they work too, had to happen someday
.
Re: Linked Script Wildcards?
Posted: Fri Apr 17, 2009 11:33 am
by DeletedAccount
Solar wrote:
Toying with the linker script is the wrong solution for this (very valid) problem, IMHO.
But sometimes , when things are broken don't fix them
. It can save you hours of explanation later .
Your are correct solar , I did say it is a quick fix , and not a good one
Regards
Shrek