aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2015-09-20 12:20:19 +0930
committerAlan Modra <amodra@gmail.com>2015-09-20 15:52:27 +0930
commit9b8b325a1f4cdaf235e7d803849dde6ededec865 (patch)
treef9705d4b1b4e10dbb5a5453e944a31f798457088 /ld
parent25f004c8dd2d96f92ea8f18217a04212f907eb94 (diff)
downloadgdb-9b8b325a1f4cdaf235e7d803849dde6ededec865.zip
gdb-9b8b325a1f4cdaf235e7d803849dde6ededec865.tar.gz
gdb-9b8b325a1f4cdaf235e7d803849dde6ededec865.tar.bz2
Add --no-dynamic-linker option to ld, for static PIE use
Inhibits output of .interp section in ELF executables. include/ * bfdlink.h (struct bfd_link_info): Add "nointerp" field. bfd/ * elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create .interp when info->nointerp. (bfd_elf_size_dynamic_sections): Adjust assert. * elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp when info->nointerp. * elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise. * elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise. * elf32-cris.c (elf_cris_size_dynamic_sections): Likewise. * elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise. * elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise. * elf32-i370.c (i370_elf_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_size_dynamic_sections): Likewise. * elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise. * elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise. * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise. * elf32-metag.c (elf_metag_size_dynamic_sections): Likewise. * elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise. * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise. * elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise. * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. * elf32-s390.c (elf_s390_size_dynamic_sections): Likewise. * elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-sh.c (sh_elf_size_dynamic_sections): Likewise. * elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise. * elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise. * elf32-vax.c (elf_vax_size_dynamic_sections): Likewise. * elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise. * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise. * elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise. * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise. * elf64-s390.c (elf_s390_size_dynamic_sections): Likewise. * elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise. * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise. * elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise. * elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise. * elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise. ld/ * ld.texinfo (--no-dynamic-linker): Document. * ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER. * lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/ld.texinfo7
-rw-r--r--ld/ldlex.h1
-rw-r--r--ld/lexsup.c7
4 files changed, 21 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e73abeb..e1e06b8 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-20 Rich Felker <dalias@libc.org>
+
+ * ld.texinfo (--no-dynamic-linker): Document.
+ * ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER.
+ * lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.
+
2015-09-18 Alan Modra <amodra@gmail.com>
* ld.texinfo: Document PowerPC64 --{no-,}save-restore-funcs.
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index c5d39d5..6b7fac8 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1455,6 +1455,13 @@ generating dynamically linked ELF executables. The default dynamic
linker is normally correct; don't use this unless you know what you are
doing.
+@kindex --no-dynamic-linker
+@item --no-dynamic-linker
+When producing an executable file, omit the request for a dynamic
+linker to be used at load-time. This is only meaningful for ELF
+executables that contain dynamic relocations, and usually requires
+entry point code that is capable of processing these relocations.
+
@kindex --fatal-warnings
@kindex --no-fatal-warnings
@item --fatal-warnings
diff --git a/ld/ldlex.h b/ld/ldlex.h
index 5629ef1..6f11e7b 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -33,6 +33,7 @@ enum option_values
OPTION_DEFSYM,
OPTION_DEMANGLE,
OPTION_DYNAMIC_LINKER,
+ OPTION_NO_DYNAMIC_LINKER,
OPTION_SYSROOT,
OPTION_EB,
OPTION_EL,
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 5dc56dc..fdd39a7 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -138,6 +138,9 @@ static const struct ld_option ld_options[] =
{ {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
TWO_DASHES },
+ { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
+ '\0', NULL, N_("Produce an executable with no program interpreter header"),
+ TWO_DASHES },
{ {"library", required_argument, NULL, 'l'},
'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
{ {"library-path", required_argument, NULL, 'L'},
@@ -761,6 +764,10 @@ parse_args (unsigned argc, char **argv)
case 'I': /* Used on Solaris. */
case OPTION_DYNAMIC_LINKER:
command_line.interpreter = optarg;
+ link_info.nointerp = 0;
+ break;
+ case OPTION_NO_DYNAMIC_LINKER:
+ link_info.nointerp = 1;
break;
case OPTION_SYSROOT:
/* Already handled in ldmain.c. */