summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2014-12-22 14:17:22 +0000
committerkettenis <kettenis@openbsd.org>2014-12-22 14:17:22 +0000
commitebca08ee1327a386e7b0bf3ba1d2699b387df922 (patch)
tree2baa961b8f98f984bc04fbd20fbfd5af53dd07be
parentTeach ld(1) not to add a PT_INTERP entry for -static -pie. (diff)
downloadwireguard-openbsd-ebca08ee1327a386e7b0bf3ba1d2699b387df922.tar.xz
wireguard-openbsd-ebca08ee1327a386e7b0bf3ba1d2699b387df922.zip
Teach ld(1) not to add a PT_INTERP entry for -static -pie.
ok kurt@
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf32-hppa.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf32-m68k.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf32-sh.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf32-vax.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf64-alpha.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf64-hppa.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elflink.c3
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elfxx-ia64.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c2
-rw-r--r--gnu/usr.bin/binutils-2.17/ld/ldmain.c3
14 files changed, 16 insertions, 14 deletions
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf32-hppa.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-hppa.c
index 51c210e5b1c..1682c7b491f 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-hppa.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-hppa.c
@@ -2155,7 +2155,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (htab->etab.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (info->executable && !info->static_link)
{
sec = bfd_get_section_by_name (dynobj, ".interp");
if (sec == NULL)
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c
index 754aa52254d..081432a1bf8 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-i386.c
@@ -1902,7 +1902,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-2.17/bfd/elf32-m68k.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-m68k.c
index df988a84966..f74cd96fa33 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-m68k.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-m68k.c
@@ -1282,7 +1282,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-2.17/bfd/elf32-ppc.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c
index 53d1046bb8c..12199c8122e 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c
@@ -4655,7 +4655,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-2.17/bfd/elf32-sh.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-sh.c
index d9e0a20ccd8..0d38114943c 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-sh.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-sh.c
@@ -4269,7 +4269,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-2.17/bfd/elf32-vax.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-vax.c
index bf481e459e7..4f8633ed299 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-vax.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-vax.c
@@ -1130,7 +1130,7 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *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-2.17/bfd/elf64-alpha.c b/gnu/usr.bin/binutils-2.17/bfd/elf64-alpha.c
index 76d0661a116..865564379ca 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf64-alpha.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf64-alpha.c
@@ -2723,7 +2723,7 @@ elf64_alpha_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 (dynobj, ".interp");
BFD_ASSERT (s != NULL);
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf64-hppa.c b/gnu/usr.bin/binutils-2.17/bfd/elf64-hppa.c
index 0f8079ca309..bad272adeb9 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf64-hppa.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf64-hppa.c
@@ -1645,7 +1645,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-2.17/bfd/elf64-x86-64.c b/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c
index 9befd69c5df..752d6be212e 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf64-x86-64.c
@@ -1717,7 +1717,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-2.17/bfd/elflink.c b/gnu/usr.bin/binutils-2.17/bfd/elflink.c
index 96790f0a90d..afb05a7996f 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elflink.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elflink.c
@@ -177,7 +177,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_with_flags (abfd, ".interp",
flags | SEC_READONLY);
@@ -5058,7 +5058,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-2.17/bfd/elfxx-ia64.c b/gnu/usr.bin/binutils-2.17/bfd/elfxx-ia64.c
index 6b3257afdf1..ca7eb6cc9a4 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elfxx-ia64.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elfxx-ia64.c
@@ -3535,7 +3535,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-2.17/bfd/elfxx-mips.c b/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c
index 9df8823ae5c..7e0ed884546 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c
@@ -7263,7 +7263,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-2.17/bfd/elfxx-sparc.c b/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c
index a4b8de9f507..1bf20119a33 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elfxx-sparc.c
@@ -2145,7 +2145,7 @@ _bfd_sparc_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-2.17/ld/ldmain.c b/gnu/usr.bin/binutils-2.17/ld/ldmain.c
index 246224072fc..84c26962324 100644
--- a/gnu/usr.bin/binutils-2.17/ld/ldmain.c
+++ b/gnu/usr.bin/binutils-2.17/ld/ldmain.c
@@ -371,6 +371,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. */