Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #585
| Newsgroups | comp.os.linux.development.apps |
|---|---|
| Date | 2013-04-23 12:56 -0700 |
| References | <2f2f7f01-d728-49bd-af16-65559cd27bf5@googlegroups.com> <pK-dnXneH61dNOvM4p2dnAA@giganews.com> |
| Message-ID | <bd9d8e76-92cd-4969-881e-a7bb2a2b8056@googlegroups.com> (permalink) |
| Subject | Re: environment variables in ld scripts |
| From | Jay Braun <lyngwyst@gmail.com> |
We decided to build a bash script that generates the ld script with a multi-line echo. Environment variables are part of the script, and are written to the temporary ld file as full path names. The bash script them does a "chmod +x" on the ld file, and executes it. The ld file can then be deleted because the bash script has the permanent contents. Thanks very much, Jay On Tuesday, April 23, 2013 8:34:29 AM UTC-7, John Reiser wrote: > > I have inherited an application that makes extensive use of ld scripts. ... > > > > > -L $APP_LIBS -( -lnwiss -lr -) > > The shell expands environment variable APP_LIBS here as part of a ld (or gcc) command line. > > > > > @$APP_LIBS lib.ld > > Inside a linker script, then ld does not expand shell environment variables. > > > > > Is there a special notation for employing environment variables in ld scripts? > > No; instead you must perform the expansion before invoking ld. > > One way to do this is with a shell "Here Document" which is invoked by the syntax "<<". > > See the documentation for any shell, such as "man bash" or "info bash". > > Example: > > > > cat - > my_linker_script.txt < > @$APP_LIBS lib.ld > > EOF > > > > The shell will expand "$APP_LIBS" as it reads the lines until EOF. > > The utility program 'cat' then writes those lines to its stdout, > > which in this case is re-directed to file "my_linker_script.txt". > > > > ld ... -T my_linker_script.txt ... > > > > Use the file my_linker_script.txt with the already-expanded environment variables. > > > > --
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
environment variables in ld scripts Jay Braun <lyngwyst@gmail.com> - 2013-04-22 17:31 -0700
Re: environment variables in ld scripts Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2013-04-23 14:50 +0300
Re: environment variables in ld scripts John Reiser <jreiserfl@comcast.net> - 2013-04-23 08:34 -0700
Re: environment variables in ld scripts Jay Braun <lyngwyst@gmail.com> - 2013-04-23 12:56 -0700
Re: environment variables in ld scripts Jay Braun <lyngwyst@gmail.com> - 2013-04-23 12:56 -0700
csiph-web