[PATCH] SH: ld support for PIE
kaz Kojima
kkojima@rr.iij4u.or.jp
Tue Jun 3 04:53:00 GMT 2003
Hi,
The appended patch is an SH portion of the PIE patch
<URL:http://sources.redhat.com/ml/binutils/2003-05/msg00832.html>.
I've tested it on sh-elf, sh4-unknown-linux-gnu, sh64-elf and
sh64-unknown-linux-gnu with no new regressions.
I've set GENERATE_PIE_SCRIPT to yes only for linux, since the user
of PIE would be linux only at present and it can be easily set for
others if they needed.
Committed.
Regards,
kaz
--
2003-06-03 Kaz Kojima <kkojima@rr.iij4u.or.jp>
[bfd/ChageLog]
* elf32-sh.c (sh_elf_size_dynamic_sections): Create .interp section
and DT_DEBUG dynamic tag even for position independent executables.
* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewize.
[ld/ChangeLog]
* emulparams/shlelf_linux.sh (GENERATE_PIE_SCRIPT): Set to yes.
* emulparams/shlelf32_linux.sh (GENERATE_PIE_SCRIPT): Likewize.
diff -u3prN ORIG/src/bfd/elf32-sh.c LOCAL/src/bfd/elf32-sh.c
--- ORIG/src/bfd/elf32-sh.c Tue May 13 20:54:03 2003
+++ LOCAL/src/bfd/elf32-sh.c Mon Jun 2 15:44:44 2003
@@ -4338,7 +4338,7 @@ sh_elf_size_dynamic_sections (output_bfd
if (htab->root.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (! info->shared)
+ if (info->executable)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
@@ -4500,7 +4500,7 @@ sh_elf_size_dynamic_sections (output_bfd
#define add_dynamic_entry(TAG, VAL) \
bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
- if (! info->shared)
+ if (info->executable)
{
if (! add_dynamic_entry (DT_DEBUG, 0))
return FALSE;
diff -u3prN ORIG/src/bfd/elf64-sh64.c LOCAL/src/bfd/elf64-sh64.c
--- ORIG/src/bfd/elf64-sh64.c Sun May 11 15:54:07 2003
+++ LOCAL/src/bfd/elf64-sh64.c Mon Jun 2 15:46:50 2003
@@ -3643,7 +3643,7 @@ sh64_elf64_size_dynamic_sections (output
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (! info->shared)
+ if (info->executable)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
@@ -3777,7 +3777,7 @@ sh64_elf64_size_dynamic_sections (output
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+ if (info->executable)
{
if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
return FALSE;
diff -u3prN ORIG/src/ld/emulparams/shlelf_linux.sh LOCAL/src/ld/emulparams/shlelf_linux.sh
--- ORIG/src/ld/emulparams/shlelf_linux.sh Thu Nov 22 18:08:04 2001
+++ LOCAL/src/ld/emulparams/shlelf_linux.sh Mon Jun 2 15:52:08 2003
@@ -9,6 +9,7 @@ ARCH=sh
MACHINE=
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
DATA_START_SYMBOLS='__data_start = . ;';
diff -u3prN ORIG/src/ld/emulparams/shlelf32_linux.sh LOCAL/src/ld/emulparams/shlelf32_linux.sh
--- ORIG/src/ld/emulparams/shlelf32_linux.sh Thu Oct 10 04:09:59 2002
+++ LOCAL/src/ld/emulparams/shlelf32_linux.sh Mon Jun 2 15:52:56 2003
@@ -10,6 +10,7 @@ MACHINE=sh5
ALIGNMENT=8
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
DATA_START_SYMBOLS='PROVIDE (___data = .);'
More information about the Binutils
mailing list