This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PowerPC STT_GNU_IFUNC support
Patch 2 of 2.
This avoids packing iplt into plt for powerpc. I believe the way HJ
has done this for x86 and x86_64 is a mistake. iplt entries for local
functions (ie. no symbol) are like normal plt entries but they differ
in one important aspect, at least with current glibc ld.so support:
They cannot be relocated lazily. For that reason, and because they
use new relocations, I reckon these entries should not be counted in
DT_PLTRELSZ, which sizes the PLT. This happens to simplify the
powerpc glibc support for ifunc too.
Another mistake is in the naming of __rel_iplt_start et al. Relocs
marked out by these symbols are used not just in .iplt, but in other
sections, eg. to relocate initialised function pointer variables in
static executables. I think something like __irel_start/__irel_end
would be less confusing, but I've left this unchanged since a glibc
change would also be needed.
* emulparams/elf32ppc.sh (PLT): Don't include ".iplt".
* emulparams/elf_i386.sh (IREL_IN_PLT): Define.
* emulparams/elf_x86_64.sh (IREL_IN_PLT): Define.
* scripttempl/elf.sc: Create separate .iplt and .rela.iplt sections
when !IREL_IN_PLT.
Index: ld/emulparams/elf32ppc.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32ppc.sh,v
retrieving revision 1.22
diff -u -p -r1.22 elf32ppc.sh
--- ld/emulparams/elf32ppc.sh 10 Jul 2009 12:19:58 -0000 1.22
+++ ld/emulparams/elf32ppc.sh 29 Jul 2009 09:40:19 -0000
@@ -11,7 +11,7 @@ SEPARATE_GOTPLT=0
BSS_PLT=
GOT=".got ${RELOCATING-0} : SPECIAL { *(.got) }"
GOTPLT=".plt ${RELOCATING-0} : SPECIAL { *(.plt) }"
-PLT=".plt ${RELOCATING-0} : SPECIAL { *(.plt) *(.iplt) }
+PLT=".plt ${RELOCATING-0} : SPECIAL { *(.plt) }
.iplt ${RELOCATING-0} : { *(.iplt) }"
OTHER_TEXT_SECTIONS="*(.glink)"
EXTRA_EM_FILE=ppc32elf
Index: ld/emulparams/elf_i386.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386.sh,v
retrieving revision 1.9
diff -u -p -r1.9 elf_i386.sh
--- ld/emulparams/elf_i386.sh 22 Oct 2008 05:20:44 -0000 1.9
+++ ld/emulparams/elf_i386.sh 29 Jul 2009 09:40:19 -0000
@@ -12,3 +12,4 @@ GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
NO_SMALL_DATA=yes
SEPARATE_GOTPLT=12
+IREL_IN_PLT=
Index: ld/emulparams/elf_x86_64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_x86_64.sh,v
retrieving revision 1.21
diff -u -p -r1.21 elf_x86_64.sh
--- ld/emulparams/elf_x86_64.sh 22 Oct 2008 05:20:44 -0000 1.21
+++ ld/emulparams/elf_x86_64.sh 29 Jul 2009 09:40:19 -0000
@@ -14,6 +14,7 @@ GENERATE_PIE_SCRIPT=yes
NO_SMALL_DATA=yes
LARGE_SECTIONS=yes
SEPARATE_GOTPLT=24
+IREL_IN_PLT=
if [ "x${host}" = "x${target}" ]; then
case " $EMULATION_LIBPATH " in
Index: ld/scripttempl/elf.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf.sc,v
retrieving revision 1.91
diff -u -p -r1.91 elf.sc
--- ld/scripttempl/elf.sc 6 Jun 2009 22:39:25 -0000 1.91
+++ ld/scripttempl/elf.sc 29 Jul 2009 11:43:19 -0000
@@ -113,7 +113,9 @@ if test -z "${INITIAL_READONLY_SECTIONS}
INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
fi
if test -z "$PLT"; then
- PLT=".plt ${RELOCATING-0} : { *(.plt) *(.iplt)}"
+ IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
+ PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} }
+ ${IREL_IN_PLT-$IPLT}"
fi
test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
if test -z "$GOT"; then
@@ -124,6 +126,20 @@ if test -z "$GOT"; then
GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) }"
fi
fi
+REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }"
+RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }"
+REL_IPLT=".rel.iplt ${RELOCATING-0} :
+ {
+ ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
+ *(.rel.iplt)
+ ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
+ }"
+RELA_IPLT=".rela.iplt ${RELOCATING-0} :
+ {
+ ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
+ *(.rela.iplt)
+ ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
+ }"
DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
@@ -326,8 +342,10 @@ eval $COMBRELOCCAT <<EOF
.rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
.rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
${REL_LARGE}
- .rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }
- .rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }
+ ${IREL_IN_PLT+$REL_IFUNC}
+ ${IREL_IN_PLT+$RELA_IFUNC}
+ ${IREL_IN_PLT-$REL_IPLT}
+ ${IREL_IN_PLT-$RELA_IPLT}
EOF
if [ -n "$COMBRELOC" ]; then
@@ -351,16 +369,16 @@ cat >> ldscripts/dyntmp.$$ <<EOF
.rel.plt ${RELOCATING-0} :
{
*(.rel.plt)
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
- *(.rel.iplt)
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
+ ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
+ ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
+ ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
}
.rela.plt ${RELOCATING-0} :
{
*(.rela.plt)
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
- *(.rela.iplt)
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
+ ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
+ ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
+ ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
}
${OTHER_PLT_RELOC_SECTIONS}
EOF
--
Alan Modra
Australia Development Lab, IBM