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]

Re: PATCH for i386: --no-copy-relocs


"H . J . Lu" <hjl@lucon.org> writes:

> On Wed, Jun 20, 2001 at 12:22:03AM -0700, Ian Lance Taylor wrote:
> > 
> > The COPY reloc is used when a variable appears in a shared library,
> > and it is referenced by the main executable, and the main executable
> > does not use the GOT to reference it.  We have two choices: 1) put a
> 
> I see. So if the main executable is compiled with PIC, should the
> linker still generate the COPY reloc?

A program compiled PIC normally does not require a reloc in the text
segment.  So normally the COPY reloc is not needed in such a case.

That suggests the possibility of changing the linker to only generate
a COPY reloc for a symbol which is referenced from a SEC_READONLY
section.  For example, this will currently generate a COPY reloc if i
is defined in a shared library:

extern int i;
int *p = &i;

However, the COPY reloc in this case does not help eliminate
relocations from the text segment, and in fact serves no terribly
useful purpose.  It would be just as good to keep the reloc for p in
the data segment as it is to generate the COPY reloc for i.

Similarly, I agree that if a GLOB_DAT relocation is required for i
(e.g. it is referred to by PIC code) and there are no other references
to i from the text section, then as far as I can see adding a COPY
reloc serves no purpose.

Ian


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