LDSCRIPTS

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

LDSCRIPTS

John Pierce
Could someone help me to understand what ldscripts are exactly, how
they relate to ldconfig (ld.so.conf), and any other pertinent
information. I have built an x86_64 single lib system and in my
ldscripts dir there are 386 scripts. I want to remove those scripts
leaving the x86_64 scripts.

This is the first part of this particular script.
elf_x86_64.x:

OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
             "elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib64");
SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64");
SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib");
SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib");
SEARCH_DIR("/usr/lib");

Why does the OUTPUT_FORMAT have three of "elf64-x86-64"?
Can I remove i386 from the OUTPUT_ARCH?
When I built my 64bit libs I put them in the lib usr/lib directories,
can I remove these paths from the SEARCH_DIR's?

Why are there so many different scripts for each arch?

elf_i386.x elf_i386.xbn elf_i386.xc elf_i386.xd elf_i386.xdc
elf_i386.xdw elf_i386.xn elf_i386.xr elf_i386.xs elf_i386.xsc
elf_i386.xsw elf_i386.xu elf_i386.xw

elf_x86_64.x elf_x86_64.xc elf_x86_64.xdc elf_x86_64.xn elf_x86_64.xs
elf_x86_64.xsw elf_x86_64.xw elf_x86_64.xbn elf_x86_64.xd
elf_x86_64.xdw elf_x86_64.xr elf_x86_64.xsc elf_x86_64.xu

And are these a.out?
i386linux.x  i386linux.xbn  i386linux.xn  i386linux.xr  i386linux.xu

I tried google but there is not a lot of information out there.
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

Daniel Jacobowitz-2
On Wed, Aug 10, 2005 at 07:30:43PM -0500, John Pierce wrote:
> Could someone help me to understand what ldscripts are exactly, how

Inputs for GNU ld.

> they relate to ldconfig (ld.so.conf), and any other pertinent

Not at all.

> information. I have built an x86_64 single lib system and in my
> ldscripts dir there are 386 scripts. I want to remove those scripts
> leaving the x86_64 scripts.

You've left out the most important thing: why?


--
Daniel Jacobowitz
CodeSourcery, LLC
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

John Pierce
Is there a reason I should not?
Could they affect the build of other sources that are lib lib64 sensitive?
If I limit my system to just x86_64 and edit those scripts to look in
directories that do in fact exist, could that maby speed up my system
fractionally?
What about the other scripts not for my system? Do I need them?

Just trying to understand everything I can about linux. I am not a
programmer/hacker/maintainer/whatever so this is the road I'm taking
to learn it.

On 8/10/05, Daniel Jacobowitz <[hidden email]> wrote:

> On Wed, Aug 10, 2005 at 07:30:43PM -0500, John Pierce wrote:
> > Could someone help me to understand what ldscripts are exactly, how
>
> Inputs for GNU ld.
>
> > they relate to ldconfig (ld.so.conf), and any other pertinent
>
> Not at all.
>
> > information. I have built an x86_64 single lib system and in my
> > ldscripts dir there are 386 scripts. I want to remove those scripts
> > leaving the x86_64 scripts.
>
> You've left out the most important thing: why?
>
>
> --
> Daniel Jacobowitz
> CodeSourcery, LLC
>
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

John Pierce
How do these scripts differ form ldconfig?
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

Christopher Faylor-3
On Wed, Aug 10, 2005 at 08:09:52PM -0500, John Pierce wrote:
>How do these scripts differ form ldconfig?

They differ in pretty much the same way that /etc/passwd differs
from /etc/termcap.

cgf
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

Jim Wilson-6
In reply to this post by John Pierce
On Wed, 2005-08-10 at 17:30, John Pierce wrote:
> Could someone help me to understand what ldscripts are exactly

See the documention
    http://sourceware.org/binutils/docs-2.16/ld/Scripts.html#Scripts

Linker scripts are not meant to be modified by end users.  They should
only be modified by toolchain developers.

This is in contrast to /etc/ld.so.conf which may need to be modified by
end users when configuring a system.

Having said that, deleting non-existent directories from a linker script
should be safe, but it probably won't do anything, because the linker
won't use that script unless you specify special linker commands, which
you shouldn't be doing either.  If you really don't want those
directories in there, you should be modifying the binutils sources to
support an x86_64 single-lib system, so that the linker will have the
desired search dirs built in from the start.  But then you probably
shouldn't be doing that either, as that may cause other problems later
on, unless you are willing to deal with those other problems.
--
Jim Wilson, GNU Tools Support, http://www.specifix.com

Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

John Pierce
> Linker scripts are not meant to be modified by end users.  They should
> only be modified by toolchain developers.

I guess you could say that I am a toolchain developer (for my own
system), as I build gnu/linux from sources.
 
> This is in contrast to /etc/ld.so.conf which may need to be modified by
> end users when configuring a system.

If my understanding is correct /etc/ld.so.conf is for already
compilied programs looking for their shared libs.

So (btw, thanks for the url to doc) the linker is for linking libs to
objects. I addressed the modification issue below, however if I were
to put libs in nonstandard locations could I again modify the scripts
to reflect?

> Having said that, deleting non-existent directories from a linker script
> should be safe, but it probably won't do anything, because the linker
> won't use that script unless you specify special linker commands, which
> you shouldn't be doing either.  

If I did do this will the linker know it was modified? Are you saying
that if I did the linker will not use the script?

>If you really don't want those
> directories in there, you should be modifying the binutils sources to
> support an x86_64 single-lib system, so that the linker will have the
> desired search dirs built in from the start.

I have built my system to be single lib (64bit modified to be put in
/lib /usr/lib).

Is there a way to modify the configure to be only single lib?
I only found one occurance in the source for lib64 dealing with
x86-64. And that was in (binutils source)/ld/configure.host.

>  But then you probably
> shouldn't be doing that either, as that may cause other problems later
> on, unless you are willing to deal with those other problems.

The problems I did experience were easily fixed.

I also un
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

Jim Wilson-6
On Wed, 2005-08-10 at 20:22, John Pierce wrote:
> If my understanding is correct /etc/ld.so.conf is for already
> compilied programs looking for their shared libs.

Yes.

> So (btw, thanks for the url to doc) the linker is for linking libs to
> objects. I addressed the modification issue below, however if I were
> to put libs in nonstandard locations could I again modify the scripts
> to reflect?

Yes.  I don't know all of the details of how linker scripts work.  I've
never tried to modify installed ones.  I suggest looking at the linker
sources, or just trying it and see what happens.

> If I did do this will the linker know it was modified? Are you saying
> that if I did the linker will not use the script?

I don't know.  Just try it, or try looking at the linker sources.

> Is there a way to modify the configure to be only single lib?
> I only found one occurance in the source for lib64 dealing with
> x86-64. And that was in (binutils source)/ld/configure.host.

gcc has a --disable-multilibs option that will prevent building multiple
libraries.  I don't know if binutils has an equivalent for the linker.
I'm guessing no, because people generally don't worry about the linker
searching extra directories.  Generally, people only care when the
linker isn't searching enough directories, as that means you will get
linker errors.

The stuff in ld/configure.host you spotted is for running the ld
testsuite.  It isn't relevant.
--
Jim Wilson, GNU Tools Support, http://www.specifix.com

Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

Ian Lance Taylor
In reply to this post by John Pierce
John Pierce <[hidden email]> writes:

> Could someone help me to understand what ldscripts are exactly,

Linker scripts are documented here:
    http://sourceware.org/binutils/docs-2.16/ld/Scripts.html
(I wrote the current version of the linker script docs, so I think
they are OK, but I'm sure they could use some improvement.)

> how they relate to ldconfig (ld.so.conf),

ld.so.conf is completely different, and has nothing whatsoever to do
with linker scripts.  ld.so.conf is documented, more or less, in the
ldconfig man page.

> I have built an x86_64 single lib system and in my
> ldscripts dir there are 386 scripts. I want to remove those scripts
> leaving the x86_64 scripts.

Go ahead.  At worst you will be unable to link 386 code, but I assume
you are prepared for that eventuality.

> This is the first part of this particular script.
> elf_x86_64.x:
>
> OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
>              "elf64-x86-64")
> OUTPUT_ARCH(i386:x86-64)
> ENTRY(_start)
> SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib64");
> SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64");
> SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib");
> SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib");
> SEARCH_DIR("/usr/lib");
>
> Why does the OUTPUT_FORMAT have three of "elf64-x86-64"?

The targets are the ones used for default endianness, explicit
big-endian, explicit little-endian, respectively.  Of course x86-64 is
always little endian so in this case the same format is used in all
cases.

> Can I remove i386 from the OUTPUT_ARCH?

No.

> When I built my 64bit libs I put them in the lib usr/lib directories,
> can I remove these paths from the SEARCH_DIR's?

Which ones do you want to remove?  You can certainly remove SEARCH_DIR
entries which names directories in which there are no files.

> Why are there so many different scripts for each arch?
>
> elf_i386.x elf_i386.xbn elf_i386.xc elf_i386.xd elf_i386.xdc
> elf_i386.xdw elf_i386.xn elf_i386.xr elf_i386.xs elf_i386.xsc
> elf_i386.xsw elf_i386.xu elf_i386.xw
>
> elf_x86_64.x elf_x86_64.xc elf_x86_64.xdc elf_x86_64.xn elf_x86_64.xs
> elf_x86_64.xsw elf_x86_64.xw elf_x86_64.xbn elf_x86_64.xd
> elf_x86_64.xdw elf_x86_64.xr elf_x86_64.xsc elf_x86_64.xu

They are used for different combinations of flags.  if you want to see
the different cases, see ld/genscripts.sh in the source code.

> And are these a.out?
> i386linux.x  i386linux.xbn  i386linux.xn  i386linux.xr  i386linux.xu

Yes, those are used for a.out.

Ian
Reply | Threaded
Open this post in threaded view
|

Re: LDSCRIPTS

Ian Lance Taylor
Ian Lance Taylor <[hidden email]> writes:

> John Pierce <[hidden email]> writes:
>
> > I have built an x86_64 single lib system and in my
> > ldscripts dir there are 386 scripts. I want to remove those scripts
> > leaving the x86_64 scripts.
>
> Go ahead.  At worst you will be unable to link 386 code, but I assume
> you are prepared for that eventuality.

I should add that for the default target the linker script is compiled
into the linker binary itself.  The files in ldscripts are only used
for non-default targets (as selected by a -m option).  Removing or
editing the files in the ldscripts directory for the default target
will have no effect.

Ian