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]
Other format: [Raw text]

Re: [PATCH] Clearing st_value of PLT SHN_UNDEF symbols if pointer equality not needed for x86-64


On Fri, Apr 23, 2004 at 08:49:12AM +0200, Andreas Jaeger wrote:
> > Is there somewhere (in the gas or ld manuals maybe?) this sort of
> > gotcha can be written down?  Otherwise the voodoo will be lost.
> 
> I agree with Daniel, we should document this somewhere.

Like this or is some other doc location better (or wording)?

2004-04-23  Jakub Jelinek  <jakub@redhat.com>

	* gen-doc.texi: Set I386 and X86_64.
	* ld.texinfo (i386, x86-64): Document function pointer equality
	handling.

--- ld/gen-doc.texi.jj	2003-04-02 14:01:15.000000000 +0200
+++ ld/gen-doc.texi	2004-04-23 10:22:56.916332686 +0200
@@ -4,6 +4,8 @@
 
 @c 2. Specific target machines
 @set H8300
+@set I386
+@set X86_64
 @set I960
 @set ARM
 @set HPPA
--- ld/ld.texinfo.jj	2004-04-22 16:38:33.000000000 +0200
+++ ld/ld.texinfo	2004-04-23 10:28:40.226806979 +0200
@@ -143,6 +143,12 @@ section entitled ``GNU Free Documentatio
 @ifset Renesas
 * Renesas::                     ld and other Renesas micros
 @end ifset
+@ifset I386
+* i386::                        ld and the Intel IA-32 family
+@end ifset
+@ifset X86_64
+* x86-64::                      ld and the AMD x86-64 family
+@end ifset
 @ifset I960
 * i960::                        ld and the Intel 960 family
 @end ifset
@@ -4590,6 +4596,12 @@ functionality are not listed.
 @ifset H8300
 * H8/300::                      @command{ld} and the H8/300
 @end ifset
+@ifset I386
+* i386::                        @command{ld} and the Intel IA-32 family
+@end ifset
+@ifset X86_64
+* x86-64::                      @command{ld} and the AMD x86-64 family
+@end ifset
 @ifset I960
 * i960::                        @command{ld} and the Intel 960 family
 @end ifset
@@ -4683,6 +4695,57 @@ options are required for these chips.
 @end ifset
 @end ifclear
 
+@ifset I386
+@ifclear GENERIC
+@raisesections
+@end ifclear
+@node i386
+@section @command{ld} and the Intel IA-32 Family
+
+@cindex i386 support
+
+The ELF linker doesn't ensure function pointer equality between executable
+and shared libraries if only PC relative relocations (@code{R_386_PC32}
+or @code{R_386_PLT32}) are used in the executable and the symbol is not
+defined in the executable.  These relocations are used for function
+pointers only in @code{call} instructions in compiler generated code
+and there function pointer equality is not needed.  If the address of
+some function not defined in the executable is taken in it, the relocation
+will resolve to the corresponding @code{PLT} slot in the executable.
+If at least one relocation, other than the above listed two, in the executable
+is resolved to the @code{PLT} slot, the linker ensures in cooperation with
+the loader that function pointers against the same symbol in shared libraries
+will resolve to the @code{PLT} slot in the executable.  But if only the
+above two relocations are used for that symbol, relocations against that
+symbol in shared libraries can resolve directly to the function definition.
+@end ifset
+
+@ifset X86_64
+@ifclear GENERIC
+@raisesections
+@end ifclear
+
+@node x86-64
+@section @command{ld} and the AMD x86-64 Family
+
+@cindex x86-64 support
+
+The ELF linker doesn't ensure function pointer equality between executable
+and shared libraries if only PC relative relocations (@code{R_X86_64_PC32}
+or @code{R_X86_64_PLT32}) are used in the executable and the symbol is not
+defined in the executable.  These relocations are used for function
+pointers only in @code{call} instructions in compiler generated code
+and there function pointer equality is not needed.  If the address of
+some function not defined in the executable is taken in it, the relocation
+will resolve to the corresponding @code{PLT} slot in the executable.
+If at least one relocation, other than the above listed two, in the executable
+is resolved to the @code{PLT} slot, the linker ensures in cooperation with
+the loader that function pointers against the same symbol in shared libraries
+will resolve to the @code{PLT} slot in the executable.  But if only the
+above two relocations are used for that symbol, relocations against that
+symbol in shared libraries can resolve directly to the function definition.
+@end ifset
+
 @ifset I960
 @ifclear GENERIC
 @raisesections

	Jakub


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