summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2014-12-22 14:09:58 +0000
committerkettenis <kettenis@openbsd.org>2014-12-22 14:09:58 +0000
commit2d6de53b6832b1a63b46fdbe0f539ec82f5350ac (patch)
treeccfdd23967fcf31e2873109ee1f30c5c93c7f1a7
parentSelf-relocation code for sparc64. (diff)
downloadwireguard-openbsd-2d6de53b6832b1a63b46fdbe0f539ec82f5350ac.tar.xz
wireguard-openbsd-2d6de53b6832b1a63b46fdbe0f539ec82f5350ac.zip
Teach ld(1) not to add a PT_INTERP entry for -static -pie.
ok kurt@
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-hppa.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-i386.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-m68k.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-m88k.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-ppc.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-sh.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-sparc.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf32-vax.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf64-alpha.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf64-hppa.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf64-sparc.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elf64-x86-64.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elflink.c3
-rw-r--r--gnu/usr.bin/binutils/bfd/elfxx-ia64.c2
-rw-r--r--gnu/usr.bin/binutils/bfd/elfxx-mips.c2
-rw-r--r--gnu/usr.bin/binutils/ld/ldmain.c3
16 files changed, 18 insertions, 16 deletions
diff --git a/gnu/usr.bin/binutils/bfd/elf32-hppa.c b/gnu/usr.bin/binutils/bfd/elf32-hppa.c
index d9171688111..b42b8ff2a1f 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-hppa.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-hppa.c
@@ -2036,7 +2036,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (htab->elf.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
if (s == NULL)
diff --git a/gnu/usr.bin/binutils/bfd/elf32-i386.c b/gnu/usr.bin/binutils/bfd/elf32-i386.c
index 7b173e4485c..a94bd37eba7 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-i386.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-i386.c
@@ -1720,7 +1720,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (htab->elf.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
if (s == NULL)
diff --git a/gnu/usr.bin/binutils/bfd/elf32-m68k.c b/gnu/usr.bin/binutils/bfd/elf32-m68k.c
index 39832be83cf..edf9b3df6ec 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-m68k.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-m68k.c
@@ -1117,7 +1117,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf32-m88k.c b/gnu/usr.bin/binutils/bfd/elf32-m88k.c
index 6723e6852a0..bd388387fac 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-m88k.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-m88k.c
@@ -1128,7 +1128,7 @@ elf_m88k_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf32-ppc.c b/gnu/usr.bin/binutils/bfd/elf32-ppc.c
index 201f4198d62..2d9844af7c6 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-ppc.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-ppc.c
@@ -3256,7 +3256,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (htab->elf.dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf32-sh.c b/gnu/usr.bin/binutils/bfd/elf32-sh.c
index 542a7cb347b..d46ceb61ddf 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-sh.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-sh.c
@@ -4449,7 +4449,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (htab->root.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf32-sparc.c b/gnu/usr.bin/binutils/bfd/elf32-sparc.c
index 0f94f5f31bb..9d060e92afc 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-sparc.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-sparc.c
@@ -1841,7 +1841,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf32-vax.c b/gnu/usr.bin/binutils/bfd/elf32-vax.c
index c509ccc2e4e..22efb963fe7 100644
--- a/gnu/usr.bin/binutils/bfd/elf32-vax.c
+++ b/gnu/usr.bin/binutils/bfd/elf32-vax.c
@@ -1150,7 +1150,7 @@ elf_vax_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf64-alpha.c b/gnu/usr.bin/binutils/bfd/elf64-alpha.c
index 6958da575ba..054e1796596 100644
--- a/gnu/usr.bin/binutils/bfd/elf64-alpha.c
+++ b/gnu/usr.bin/binutils/bfd/elf64-alpha.c
@@ -4056,7 +4056,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf64-hppa.c b/gnu/usr.bin/binutils/bfd/elf64-hppa.c
index 76dcc18b243..4cd939af786 100644
--- a/gnu/usr.bin/binutils/bfd/elf64-hppa.c
+++ b/gnu/usr.bin/binutils/bfd/elf64-hppa.c
@@ -1644,7 +1644,7 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf64-sparc.c b/gnu/usr.bin/binutils/bfd/elf64-sparc.c
index 90de3b974d5..1dd92ed667c 100644
--- a/gnu/usr.bin/binutils/bfd/elf64-sparc.c
+++ b/gnu/usr.bin/binutils/bfd/elf64-sparc.c
@@ -1788,7 +1788,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elf64-x86-64.c b/gnu/usr.bin/binutils/bfd/elf64-x86-64.c
index a1d62501f96..c7bd64e762c 100644
--- a/gnu/usr.bin/binutils/bfd/elf64-x86-64.c
+++ b/gnu/usr.bin/binutils/bfd/elf64-x86-64.c
@@ -1513,7 +1513,7 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (htab->elf.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
if (s == NULL)
diff --git a/gnu/usr.bin/binutils/bfd/elflink.c b/gnu/usr.bin/binutils/bfd/elflink.c
index e4714460559..4707de15838 100644
--- a/gnu/usr.bin/binutils/bfd/elflink.c
+++ b/gnu/usr.bin/binutils/bfd/elflink.c
@@ -141,7 +141,7 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
/* A dynamically linked executable has a .interp section, but a
shared library does not. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_make_section (abfd, ".interp");
if (s == NULL
@@ -4694,7 +4694,6 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
bfd_boolean all_defined;
*sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (*sinterpptr != NULL || !info->executable);
if (soname != NULL)
{
diff --git a/gnu/usr.bin/binutils/bfd/elfxx-ia64.c b/gnu/usr.bin/binutils/bfd/elfxx-ia64.c
index b19aac2c55d..881d834c18d 100644
--- a/gnu/usr.bin/binutils/bfd/elfxx-ia64.c
+++ b/gnu/usr.bin/binutils/bfd/elfxx-ia64.c
@@ -2894,7 +2894,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
/* Set the contents of the .interp section to the interpreter. */
if (ia64_info->root.dynamic_sections_created
- && info->executable)
+ && info->executable && !info->static_link)
{
sec = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (sec != NULL);
diff --git a/gnu/usr.bin/binutils/bfd/elfxx-mips.c b/gnu/usr.bin/binutils/bfd/elfxx-mips.c
index 8a1f0ea0168..5be26072a8b 100644
--- a/gnu/usr.bin/binutils/bfd/elfxx-mips.c
+++ b/gnu/usr.bin/binutils/bfd/elfxx-mips.c
@@ -5905,7 +5905,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils/ld/ldmain.c b/gnu/usr.bin/binutils/ld/ldmain.c
index 36f2fff53f7..547d1aafe4b 100644
--- a/gnu/usr.bin/binutils/ld/ldmain.c
+++ b/gnu/usr.bin/binutils/ld/ldmain.c
@@ -380,6 +380,9 @@ main (int argc, char **argv)
if (! link_info.shared || link_info.pie)
link_info.executable = TRUE;
+ if (! config.dynamic_link && link_info.pie)
+ link_info.static_link = TRUE;
+
/* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
don't see how else this can be handled, since in this case we
must preserve all externally visible symbols. */